Skip to main content
gamedev.net
🔒 Locked

SetParent

Started by elih1 Jan 2, 2009 at 1:32 AM 3 replies 1.9k views
Original Post
elih1
elih1
Hello I have Windows main form and I am trying to set child window for it, with SetParent. The child window is produced by dll from third party application that my application is calling. I am doing the following : long style = GetWindowLong(hwnd, GWL_style); style &=~WS_CAPTION; style &= ~WS_OVERLAPPED; style|=WS_CHILD; SetWindowLong(hwnd, GWL_style, style); SetParent(hwnd,hwndMain); and the window is set into the main form , but it does not work right i.e the following is happening: When I minimize the main form and maximize again the quick menu bar which consists of several buttons and the menu bar are not refreshed. What could be the reason? Thanks [Edited by - elih1 on January 2, 2009 1:21:28 PM]
LessBread
LessBread
SetWindowLong

"Remarks: Certain window data is cached, so changes you make using SetWindowLong will not take effect until you call the SetWindowPos function. Specifically, if you change any of the frame styles, you must call SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly."

WS_CAPTION and WS_OVERLAPPED are frame styles.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
elih1
elih1
Thank you for the reply.
I do the following:

long style = GetWindowLong(hwnd, GWL_style);
style &= ~WS_OVERLAPPED;
style &=~WS_CAPTION;
style|=WS_CHILD;
SetWindowLong(hwnd, GWL_style, style);
SetWindowPos(hwnd,HWND_TOP,0,0,300,300, SWP_FRAMECHANGED);
HWND result=SetParent(hwnd,hwndMain);

But I'am still getting the same behavior. When I minimize my main form and maximize again the menu bar is not shown. Also the strange thing is that when I put the mouse on the place where the menu bar should be it magically shows it self.
Any suggestions
LessBread
LessBread
SetWindowPos

"If you have changed certain window data using SetWindowLong, you must call SetWindowPos for the changes to take effect. Use the following combination for uFlags: SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED."

Before the call to SetWindowPos, try adding this.

InvalidateRect(hWnd, NULL, TRUE);

And instead of HWND_TOP, try NULL or hwndMain.

Experiment with the various parameters.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
elih1
elih1
Thank you for the reply
I'll try your suggestion

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.