Modifying Window Style From Handle

Hey,
I have a handle to a window in a different process, and I want to hide
or change the border of one of its child windows.

How can this be achieved?

I figure its probably has to do with using the WM_STYLECHANGING  and
WM_STYLECHANGED window messages but not exactly sure how.

Any help would be appreciated!

Thanks in advance,

--sternr
0
SternR (3)
7/15/2008 3:21:56 PM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
379 Views

Similar Articles

[PageSpeed] 19

You can use SetWindowLong with GWL_STYLE index.

AliR.


"sternr" <SternR@gmail.com> wrote in message 
news:bba53d90-32c8-43b5-be0d-6bb86bfc7534@k13g2000hse.googlegroups.com...
> Hey,
> I have a handle to a window in a different process, and I want to hide
> or change the border of one of its child windows.
>
> How can this be achieved?
>
> I figure its probably has to do with using the WM_STYLECHANGING  and
> WM_STYLECHANGED window messages but not exactly sure how.
>
> Any help would be appreciated!
>
> Thanks in advance,
>
> --sternr 


0
AliR3470 (3236)
7/15/2008 4:04:25 PM
>I have a handle to a window in a different process, and I want to hide
>or change the border of one of its child windows.
>
>How can this be achieved?

You'd normally use ModifyStyle(Ex) from MFC (SetWindowLong in SDK),
however there's no guarantee that a style will visibly change - many
controls only take notice of the style when they're created, I don't
know if that applies to border styles or not.

Additionally as you're working cross process, this is unlikely to work
unless you inject your code into the process with the window. Have a
look at the SetWindowLongPtr hWnd parameter documentation.

Dave
0
davidl7375 (2060)
7/15/2008 4:14:22 PM
Thanks guys for the fast reply!,
So if I want to hide the the window should this code do?

style = GetWindowLong(hwnd,GWL_STYLE);
SetWindowLong(hwnd,GWL_STYLE,style ^ WS_VISIBLE)
?

Thanks again

--sternr
0
SternR (3)
7/15/2008 4:41:14 PM
>So if I want to hide the the window should this code do?
>
>style = GetWindowLong(hwnd,GWL_STYLE);
>SetWindowLong(hwnd,GWL_STYLE,style ^ WS_VISIBLE)
>?

If you want to hide a window, use ShowWindow.

Dave
0
davidl7375 (2060)
7/15/2008 5:29:25 PM
Damn, how didn't I think of it!
Actually both solutions work.
My final problem is - how to force the window to refresh?
I've tried UpdateWindow, and RedrawWindow with the following flags:
Win32.RDW_FRAME | Win32.RDW_INVALIDATE | Win32.RDW_UPDATENOW |
Win32.RDW_ALLCHILDREN
But to no avail...
Any ideas?

Thanks again guys - you've been much help!

--sternr
0
SternR (3)
7/15/2008 6:17:30 PM
You have to call InvalidateRect before you call UpdateWindow

::InvalidateRect(hWnd,ClientRect);
::UpdateWindow(hWnd);

AliR.


"sternr" <SternR@gmail.com> wrote in message 
news:8098aa5e-058b-4a38-b1b5-da9cca8e7107@x41g2000hsb.googlegroups.com...
> Damn, how didn't I think of it!
> Actually both solutions work.
> My final problem is - how to force the window to refresh?
> I've tried UpdateWindow, and RedrawWindow with the following flags:
> Win32.RDW_FRAME | Win32.RDW_INVALIDATE | Win32.RDW_UPDATENOW |
> Win32.RDW_ALLCHILDREN
> But to no avail...
> Any ideas?
>
> Thanks again guys - you've been much help!
>
> --sternr 


0
AliR3470 (3236)
7/15/2008 6:45:35 PM
Two things wrong with this:

First, SETTING the state of the WS_VISIBLE bit does NOT change the visibility.  It merely
reflects the current state of the visibility as set by ShowWindow().

Second, ^ is the WRONG operator to use to turn a bit off.  This presumes the bit is on,
but if it is already off, it turns it on.  The CORRECT way to turn a bit of is
	style & ~WS_WHATEVER
which sets the bit to 0.

It helps readability if you put spaces after commas.  Also, you should consider using
ModifyStyle(Ex) to modify style bits.
				joe

On Tue, 15 Jul 2008 09:41:14 -0700 (PDT), sternr <SternR@gmail.com> wrote:

>Thanks guys for the fast reply!,
>So if I want to hide the the window should this code do?
>
>style = GetWindowLong(hwnd,GWL_STYLE);
>SetWindowLong(hwnd,GWL_STYLE,style ^ WS_VISIBLE)
>?
>
>Thanks again
>
>--sternr
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
7/15/2008 8:23:57 PM
SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_FRAMECHANGED)
			joe

On Tue, 15 Jul 2008 11:17:30 -0700 (PDT), sternr <SternR@gmail.com> wrote:

>Damn, how didn't I think of it!
>Actually both solutions work.
>My final problem is - how to force the window to refresh?
>I've tried UpdateWindow, and RedrawWindow with the following flags:
>Win32.RDW_FRAME | Win32.RDW_INVALIDATE | Win32.RDW_UPDATENOW |
>Win32.RDW_ALLCHILDREN
>But to no avail...
>Any ideas?
>
>Thanks again guys - you've been much help!
>
>--sternr
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
7/15/2008 8:24:58 PM
Reply:

Similar Artilces:

Handling the WorkbookAfterSave Event in VBA
I can handle the Excel WorkbookAfterSave event in VB 2010 as explained at http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.appevents_event.workbookaftersave(office.14).aspx. I can also handle built-in events of the Excel application in VBA as described at http://msdn.microsoft.com/en-us/library/aa140934(v=office.10).aspx. However, I cannot figure out how to handle the WorkbookAfterSave event in VBA. If I use a statement such as: Private WithEvents ExcelApp as Application a number of application events are available, but WorkbookAfterSave isn't on...

Can I install Office 97 on my new windows xp computer?
I had Microsoft Office 97 on my old computer operating on Windows 95. My new computer has Microsoft Works and uses Windows XP. It will not read my Office 97 Excel files from my old computer. I have the Office 97 cd. Can i install this on my new computer with Windows XP? Yes. In article <569D8416-360C-4DBB-82A6-D1090EB53395@microsoft.com>, "whitedog" <whitedog@discussions.microsoft.com> wrote: > I had Microsoft Office 97 on my old computer operating on Windows 95. My new > computer has Microsoft Works and uses Windows XP. It will not read my Office > 97 E...

Error Code 8024000E Windows Update Not Functional!
A couple of days ago my PC stopped being able to even check for or get updates. I believe that something that was installed on the update of 11/13 caused this issue because my computer suddenly has 3 problems it has never had before. Here are the lines from the log file where the process bombs out: 2009-11-14 12:34:19:709 1356 20f4 Setup WARNING: SelfUpdate failed to load WuPackages.xml file, error = 0x8024000E 2009-11-14 12:34:19:709 1356 20f4 Setup WARNING: SelfUpdate check failed to download package information, error = 0x8024000E 2009-11-14 12:34:19:709 1356 20f4 Setup FAT...

Styles in Excel
Hello: People in my company often send me their problematic Excel workbooks. Lately, I've been seeing a number of workbooks that have thousands of styles. I have some VBA code that loops through the styles collection and deletes anything that's not in use. However, often times quite a few of the styles cannot be deleted. I notice that these often have the name "Nor" and cannot be deleted through code or manually in the user interface. Does anyone know how this situation occurs? Does anyone know how to delete these? Thanks! Possibly corrupt or built-in styles? ...

Outlook rules can't be modified
One of my users is having an issue with thier Outlook client. In the Rules wizard the options to Modify/Delete/Copy the rules are all grayed out. There are no way to modify the rules once they have been created! I have searched MS Support and through the news groups, but have had no luck finding a fix for this issue. Anyone who has found a fix for this I would appreciate hearing how. Thanks. I found a way to fix the problem but it's a real pain in the butt. Here it is: I use Outlook 2002 xp for my email which is where I was having the rules problem. But I also have outlook 2000 on a...

Federal Govt Employees: How do you handle the new TSP?
How do you treat the new TSP system? As stocks? The TSP web site does not give us the transaction details (like when they bought the "shares" of C fund etc and at what price). They just give us the current balance. Will we have to wait for the quarterly statements (hopefully they'll have the individual transactions for each payroll deduction) before entering the details in Money? -- Aloke --- to reply by e-mail remove 123 and change invalid to com ...

Modify Code
I am trying to access the Itemlookup code for an item when an item is added to my screen (using hook 4).. The code I currently have loops through all the items I have on the screen. All I want is the ItemLookupCode for the item added to the screen Currently this works but loops through all my items on the screen. Dim E As Object ' QSRules.TransactionEntry For Each E In Session.Transaction.Entries LookupCode = E.Item.ItemLookupCode Next E Could someone help modify this. TIA Chuck, Try using the property below: TransactionEntry.Key Property The Key property gets the key fo...

How to import style sheets?
I pretty much use the same styles in every document. It's tedious to create a new style sheet every time I start a new document. Can I set up an external style sheet and just import it when I create a new document? Two thoughts offhand: 1- When you create your styles why not select the option at the bottom of the New Style dialog for "New documents based on this template"? That stores the style in the Normal.dotm rather than in the document, or 2- Related to the above, but create a template of your own which includes the styles you need & base new files on it. ...

How to forbid the Windows Updates
Hello, Windows Server 2003 Following a catastrophe after a Windows Update, I want to forbid any future Windows Update, even the option when we shutdown the server: "Install the updates and shutdown". How can I do that? Thanks Disable the Windows Update service. Start|Run|services.msc For the idiotic 'Install Updates and Shut Down' option. Start|Run|gpedit.msc Administrative Templates\Windows Components\Windows Update Do not display 'Install Updates and Shut Down' option in Shut Down Windows dialog box -- Regards, Dave P...

Windows Firewall Backward Compatibility
I want to use firewall api in my XP to open certain ports. Would it work also in Windows Vista and in Windows 7? In other words do newer Windows firewalls api support backward compatibility? Regards James James wrote: > I want to use firewall api in my XP to open certain ports. Would it work > also in Windows Vista and in Windows 7? > In other words do newer Windows firewalls api support backward > compatibility? They practically always do. It's extremely rare for Microsoft to disable previously supported API. But the best way to know for sure is ju...

DPM 2007 SP1 and Windows Server 2008 SP2 Hyper-V Failover Cluster
Should DPM 2007 SP1 be able to backup virtual machines that are in a Windows Server 2008 SP2 Hyper-V fail over cluster? Each VM has a dedicated LUN at this point in time. From previous experience the backups appear to be inconsistent from the stand point of if the machine is migrated to another host the backup breaks. Has anyone successfully implemented backups for this type of environment? DPM 2007 SP1 does officially support backing up VMs on Windows 2008 SP2 Hyper-V Clusters. -- Narendran[MSFT] This posting is provided "AS IS" with no warranties, and confer...

Why does Outlook 2002 not run in Windows 7?
I have installed an older version of MS Office on my new computer running Windows 7 OS. All of the programs work fine, except for MS Outlook 2002. Everytime I run the program it crashes with an error. I have tried downloading several updates, after uninstalling and re-installing Outlook, without any solution. The error code is below: Problem signature: Problem Event Name: APPCRASH Application Name: OUTLOOK.EXE Application Version: 10.0.6856.0 Application Timestamp: 4a7c8be7 Fault Module Name: unknown Fault Module Version: 0.0.0.0 Fault Module Timestamp: 00000...

Windows XP Update problem help needed-
Am running Operating System : Microsoft Windows XP Home Edition Version : 5.01.2600 Service Pack 3 Problem is that when I go to the Windows update site it shows the following updates available: Microsoft .NET Framework 3.5 SP1 Update for Windows Server 2003 and Windows XP x86 (KB982168) Microsoft .NET Framework 3.5 SP1 and .NET Framework 2.0 SP2 Security Update for Windows 2000, Windows Server 2003, and Windows XP x86 (KB979909) I tryed to install them along with others updates listed and it showed they succeeded along with the others but when I rest...

MS Publisher window element
I have been using MS Publisher 2007. When you go into the main window after choosing a template from the launch window, the task panes appear and you have a space for the work area. This is the region of the publisher window, where the pages of the publication are displayed. You also have a scratch area where you place Objects before placing them into the publication. I want to know what do you call this work area in the main Publisher window. Is there a term for it? If there is none appears in the Publisher help. Thank you Aarthi P.S. Please clarify the name of teh main window taht a...

Word does not remember position of window
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I have just installed office:mac 2008 on my new iMac. Exept, that Word does not remember the position of the window for allready saved documents, everything works OK. According to some comment I found in the forum, I edited a script to size and also position the active window. No problem with this script. At reopening the saved documentm the size of the window is correct but it is always positioned at the upper left corner. <br> All other office applications do remember the last position of the window. &l...

excel viewer for windows ME #2
Hi, I am using windows ME and i need a excel viewer. i do not have office installed. Where can i download this? Thanks. ...

Snake or Newspaper Style a Single-column Report
My report has one column: surname. I want this one column to snake across the page. I've looked at columns in page setup. The option to print down then across is greyed out when there is only one column. I changed the column number to two to gain access to this option and then changed it back because I really only have 1 column. All of this to no avail. Can someone help please? I need specific help on what to do and where to do it since I've tried the obvious and it doesn't seem to work. Thanks a lot! ....Dana The number of columns is the number of print ...

32-bit programs on Windows x64
Can two 32-bit programs each have access to 4.0 GB of RAM, if there is 8.0 GB of RAM on the system? "Peter Olcott" <NoSpam@SeeScreen.com> wrote: >Can two 32-bit programs each have access to 4.0 GB of RAM, >if there is 8.0 GB of RAM on the system? On a 32-bit system, each process gets a 4GB virtual memory space. At any time, bits of this space are in physical RAM, or on disk, or noplace (since they haven't been allocated yet). The OS keeps track of where everything is. If you've got 8GB of RAM, then you must have a 64-bit system. I'm not sure what the...

windows vista update(service not running)
hi when ever i click the check for updates button,it says service is not running,u need to restart your computer ,i always restart it but the same thing is all over again what shall i do? Date: 4/3/2010 6:04 AM, Author: windows vistaUpdate(service not running) Wrote: > hi > when ever i click the check for updates button,it says service is not > running,u need to restart your computer ,i always restart it but the same > thing is all over again > what shall i do? What Operating System version? What Service Pack level is installed? At what point in the update p...

Copy/Paste very slow with separate excel window
I have a spreadsheet with 32,000 rows and 15 rows. When I copy data from the spreadsheet and click File New and then paste into the spreadsheet it is very fast. BUT when I launch another Excel instance and do a paste it is very slow. Now if I delete about 15,000 rows, the copy/paste is faster. Is there some sort of limitation of Windows 2000/xp or Excel. IT happens in Excel 2000 and 2003 versions. This is for our customer service department who works in Excel all day and they say they must have several Excel windows open for some reason. Not my place to argue with them. Try t...

XP Menus style
Hi, Does anybody know how can I use the XP Menus Style in my applications. Thanks. http://www.codeproject.com/menu/bcmenu.asp -- --------------------------------------------------- Automate your software builds with Visual Build Pro http://www.kinook.com "Robe" <znroberto@hotmail.com> wrote in message news:#p0ELYf7DHA.804@tk2msftngp13.phx.gbl... > Hi, > > Does anybody know how can I use the XP Menus Style in my applications. > > Thanks. > > ...

problem in excel 97 (running in windows-xp)
hello, I have a problem in excel 97 running under windows-xp. The display of the cell "spills" over to the next cell, even though there is enough space in the cell. The same file running in excel 97 under windows 97 does not show the problem. Does anyone know that to do? ...

Launching file from Windows Exploer problem
I am always able to launch an excel file by double- clicking in the file name within Windows Explorer. But when I save an excel file as an HTML format, and keep the original .xls file, for some reason, when I double click on the .xls file, it will not launch Excel and open the file automatically. When I double click on the .html file, it does launch Internet Explorer and displays the file as expected. Any ideas why I can't get the .xls file to launch? ...

Windows 64bit Latest service pack.
Where can i find the latest service pack for windows xp 64 bit? Ernie wrote: > Where can i find the latest service pack for windows xp 64 bit? http://www.microsoft.com/downloads/details.aspx?FamilyId=893FD6C0-6283-44C3-BB84-B2F0315B2AE6&displaylang=en Service Pack 2 for Windows XP Professional, x64 Edition (There is no SP3 for XP x64, SP2 is the latest available) John Here http://www.microsoft.com/downloads/details.aspx?familyid=893FD6C0-6283-44C3-BB84-B2F0315B2AE6&displaylang=en Ernie wrote: > Where can i find the latest service pack for windows xp 64 bit? ...

Windows Server 2003 Logo?
Is it still possible to submit for Windows Server 2003 Logo? If not is there WS2K3 signability available under Windows Server 2008 Logo? Thanks, Steve WLK 1.5 is the latest logo kit available. It does allow for testing and receiving a logo for specific Windows Server 2003 devices (see http://www.microsoft.com/whdc/winlogo/categories.mspx). John Garcia [MSFT] "S. Heck" wrote in message news:40F84979-5F92-4E04-8A8B-8A482D6A0EAA@microsoft.com... Is it still possible to submit for Windows Server 2003 Logo? If not is there WS2K3 signability available under ...