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
377 Views

Similar Articles

[PageSpeed] 51

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:

Exporting to Windows Live Mail
How do I export messages from OE6 to Windows Live Mail? -- Paul If WLMail is on the same machine, it will import automatically. To go to another machine....... Transferring data from Outlook Express to Windows Live Mail: For messages: Copy the *ENTIRE* OE message store folder to a flash drive. (Folders.dbx must be included). Place this on the Desktop or other location on the machine using WLMail. Open WLMail and: File | Import | Messages | Microsoft Outlook Express 6 and point to where you saved it. OE Message Store Location: In OE: Tools | Options | Maintenance | S...

Can't edit email subject line or text in Windows Mail??
-- I can't edit email subject line or text in Windows Mail without resending it to myself. I used to have this functionality in Outlook Express [ Windows XP ]. I like to change the subject line to something more reflective of the contents of the email for when I save it in a folder. Also, many times there is a lot of junk in the body text of the email which I like to reduce to only the relevant info. In XP I could hit "edit message" in EDIT and I could change as necessary. Can someone tell me how to make changes to the Windows Mail system to allow this functionalit...

MFC app has only one windows proc?
Hi Experts: I have a few questions on a typical MFC application: 1. Is it true that an MFC app has only one Windows procedure which hadles all windows (UI) of the application? 2. What if there is model dialog or modeless diaglog in the application? 3. If there is a UI thread, will the UI thread have a Windows procdure for itself? Thanks in advance! Polaris On Wed, 4 Apr 2007 09:55:39 -0700, "Polaris" <etpolaris@hotmail.com> wrote: >Hi Experts: > >I have a few questions on a typical MFC application: > >1. Is it true that an MFC app has only one Windows ...

Money Plus Deluxe (v17) and PocketPC with Windows Mobile 6.1 #2
Hi, I use a PC version. Now I bought a phone with WinMo operating system. What can I do with such those devices? Is there a possibility to use a thin MS Money cluient in mobile device and then synchronize changes made in pocpet PC with a file in PC? ...

Windows Media Player Freezes
Windows 7 64 bit WMP 12 intermittently freezes and get message "server connection failed" I finally tried to uninstall and install WMP 11 which works fine on a Vista pc but am told I have a later version installed and cannot do that. Apparently WMP 12 cannot be uninstalled, merely disabled, so I am at a loss. I can use other players that work fine but I would like to work with WMP for various reasons. Stan ...

Outlook Window Resizing in RegEdit
I have had a problem with some software which appears to have sized the Outlook window to a size which makes it disappear from the screen. If I Alt Tab to it and hit Alt and the Down Arrow, I can see the menu's, but no window. If I Maximise it from the Task Bar then it runs full screen, but I want to run it at the original half- screen sized window. I know that there is a way of editing the size of the window in the System Registry. Does anyone know where this can be done? I am fairly competent with Reg Edit. Thanks. ...

Change Appearance of Font in Email Window
I would like to change the appearance of screen fonts in the email pane in Outlook 2003. When I open an email, there is a button on the toolbar which allows me to increase the appearance of the font size, but is there a way to make the larger size the default? Thanks. -- Frank ...

Load Dialog Resource from Windows C program
Hi, I've been writing a win32 program in C, and I'm trying to open a dialog box from a resource file. The .rc file is included in the project. I called: hDlg = CreateDialogParam(MyInstance, "MyDialog", NULL, (DLGPROC)DlgProc, 0 ); When I call GetLastError(), it returns 1407 Cannot find window class. ERROR_CANNOT_FIND_WND_CLASS . Is this an MFC command? I'm not using MFC? How do I load a dialog from a resource without using MFC, in "old-school" win32? Thanks in advance, Tom -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m...

ROYAL STYLE #10 BELTS (2)PK
List Price:$3.95 Image: http://bestdeallocator.info/image.php?id=B0015OMZLM Best price found: http://bestdeallocator.info/index.php?id=B0015OMZLM ROYAL STYLE #10 BELTS (2)PK ...

How do I lock window size
When I'm designing tables or queries I can't seem to find out how to save the window size. The size always seems to return to its original size and position whenever I open a query. Resizing the window isn't saved whether I'm in Design View, Datasheet View, or SQL View. And yet, I've coincidentally changed the window size while working in these views. Like I'd be adding fields or something and drag the window larger, and it would save it, but it was like a coincidence of steps that I can't duplicate. I can't find any option anywhere that sugge...

How to Enable Print on Both Side(Duplex) on Windows 2004
Hi, When seen on the Print options for the Printer added on Windows 2004 I am not finding the "Print on Both Sides (Duplex) option...Can any one let me know...how to enable this option on Windows 2004..I know there is such option for Windowx XP...But dont know how to do this for wn2K4 ...

How best to handle this?
I make a purchase on a credit card account. I return the item and get a store credit. I then purchase an item using the store credit plus some cash. I would like to track the purchase but do not want to create a "store credit" account. What is the best way to handle this? Thanks I handle these kinds of things with an expense category called "Miscellaneous:Deposit, credit to follow". The return would be split, say, ($20) Clothing, $20 Miscellaneous:Deposit, credit to follow for a total of $0. When I spend the credit, it's, say, $24.50 Clothing, ($20) Miscellaneous:...

Problems closing my open relay
I have an SBS 2003 server /w exchange server running as an smtp server and when I run the open relay test it says it is open. My Virtual SMTP server settings are: In the Virtual Server under the access tab and relay restrictions, I have the radio button that says [these computers are allowed and nothing is listed], Allow computers which successfully authenticate to relay is unchecked and under users - authenticated users and submit is checked? Why is my relay still open? What other settings should I be look at? Help! Thanks! In news:1166723325.464791.169400@n67g2000cwd.googlegroups.com...

Money Not Handling Like Transactions the Right Way
I have EIRAs for my two kids at T. Rowe Price. From my checking account, I transfer the same amount, on the same day of each month, to each EIRA. However, when I download from checking account into Money, it is recognizing the two events as duplicates and only shows one in my register. Any help to resolve this would be appreciated. tks SRM In microsoft.public.money, SRM wrote: >I have EIRAs for my two kids at T. Rowe Price. From my checking account, I >transfer the same amount, on the same >day of each month, to each EIRA. However, when I download from checking >accoun...

windows xp boot problem
Plz help me , i installed tune up utilities ,i changed my logon screen through tune up and then rebooted my pc now when i start xp a blank screen appears plz guide me ,what to do now. -- DINESH4033 ------------------------------------------------------------------------ DINESH4033's Profile: http://forums.techarena.in/members/239100.htm View this thread: http://forums.techarena.in/windows-xp-support/1350168.htm http://forums.techarena.in Does your system get stuck on the black screen, or it stays for few minutes and than comes the logon screen, or there is a cursor ...

can I open excel as seperate windows always?
Hello, I wonder if I can always open each and every Excel workbook as a "seperate" windows on me desktop. I'll be happy to know how. Thanks... --- Outgoing mail is certified Virus Free. (Giden posta vir�ss�z olarak belgelendi.) Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.714 / Virus Database: 470 - Release Date: 02.07.2004 go to options then view and check the box Windows in Taskbar then hit OK. Brian "Wilson" <ayes@yahoo.com> wrote in message news:uZ4eKkPYEHA.1000@TK2MSFTNGP12.phx.gbl... > Hello, > I wonder if I can alwa...

Windows 7 Shut Down
Windows 7 is a very advanced and up-to-date system which has become extremely popular since its launch - but many people are now discovering that this system is prone to shutting down randomly, leading you to lose data and unsaved games. This issue is very common and extremely damaging to your PC, and here's how to fix your PC instantly! One of the biggest causes of this problem is down to overheating. Computers are a lot like cars - they continually get hot and have to be cooled. It's often the case that if you're using your computer too much or are restricting the airf...

Check out the internet update for Windows
--inezqvjpmkhnbiprh Content-Type: multipart/related; boundary="svmwdypqsmo"; type="multipart/alternative" --svmwdypqsmo Content-Type: multipart/alternative; boundary="wrdjrfadlwqwsclrk" --wrdjrfadlwqwsclrk Content-Type: text/plain Content-Transfer-Encoding: quoted-printable MS Consumer this is the latest version of security update, the "November 2003, Cumulative Patch" update which fixes all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three newly discovered vulnerabilities. Install now ...

Excel workbooks in different windows & Fill color?
Q1 Hi, how to make excel workbooks opens in different windows? When I'm using Word all files opens in different windows and I can close each window without Word finish. Q2 How do I get different fill-colors other than those listed in the cell - format - meny? I got an english template with light grey-cells, worked all right yesterday, but today all cells with that color has become light-green. The light-grey color does not show up in the format meny - Weird! Q3 It's easy to format a cell with colors depending on values eg., but how do I cange the entire row color or several cells...

SBS 2003 R2 and Windows 7
I know there were issues with Vista Business Is there anything special required to connect Windows 7 Pro to SBS 2003? Any gotchas ? Should be the same as Vista... Installing Windows 7 in a SBS 2003 Environment http://blogs.technet.com/sbs/archive/2009/05/14/installing-windows-7-in-a-sbs-2003-environment.aspx -- Merv Porter [SBS-MVP] ============================ "sam" <sam@msforums.com> wrote in message news:eOv4le5ZKHA.5852@TK2MSFTNGP05.phx.gbl... > I know there were issues with Vista Business > > Is there anything special required to ...

Modifying XML from the client side
Hello everyone, What I would like to do is the following: to have an XML document. Send the document through XSLT to create a table like structure. Allow the user to add rows to the table like structure (thus changing the XML document) and then finally allowing the user to send the modified document to the server (or SOAP service) for persistence. I am using VS 2005 C# for the client programming. I have figured out a way to read data (from a DB not an XML) and insert it into a DOM. In this case, the DOM structure is modified by using Javascript commands to Add and Remove. But - there is a l...

Windows Live Messenger crash on Windows 7 startup
Windows Live Messenger crashes at Windows 7 startup, it happens everytime I boot my PC, if I start WLM manually it will work, how can I delay the startup of Windows Live Messenger so it starts after all other devices and services have initialized? Thanks. I have the same issue, wish someone could help with this?! "thijazi" wrote: > Windows Live Messenger crashes at Windows 7 startup, it happens everytime I > boot my PC, if I start WLM manually it will work, how can I delay the startup > of Windows Live Messenger so it starts after all other devices and s...

Windows 98 GDI limitation
This is a multi-part message in MIME format. ------=_NextPart_000_0022_01C46289.7E77D280 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, Does anybody know how to display in CView classes large amounts of data, = divided in pages? I am having some troubles with Windows 98 limitation = on CRect objects (Windows 98 GDI functions can only handle values = between -32768 and 32767). Using MM_LOMETRIC (0.01 mm), for instance, gives me a limit of = aproximately 650 cm document. Is there any kind of 'HowTo' or article on this issue...

pop up window blocks my email!
I am using Outlook 2003 as my email program. When checking my office email from home on another computer via the internet thru an exchange server, I cannot open any of my email messages due to a message that comes up at the bottom left screen coupled with the Internet Explorer icon "e" which states: "pop up window blocked". This will not allow me to open any of my messages. No matter what I try, I am unable to access my messages. I am using Windows XP as my operating system at home and at work and I have disabled my Norton, disabled pop up blockers and tried many way...

Please how do I get external .eml files to open in OE rather than Windows Live Mail?
This is a multi-part message in MIME format. ------=_NextPart_000_005F_01CAD33D.E62DD6B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Dear Everyone, Please, how do I get external .eml files to open in OE rather than = Windows Live Mail? I am running Windows XP SP3 Professional Edition. Thanks in advance and take care. Sincerely, Betty A Knight bettyaknight@comcast.net ------=_NextPart_000_005F_01CAD33D.E62DD6B0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ...