• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Need help with Win32 stuff...

## Recommended Posts

Hi, i''ve got a few problem with windows programming. I''m trying to make an "winamp"-style app, with alot of graphics. So i''d like to use the windowstyle WS_POPUP to make it as nice as possible (no windows gui gfx), but when i do, i can''t move the window! I tried setting the window pos manually, but i got alot of flickering and other problems. Another problem i have is that if i''m resizing or moving a window, it simply stops updating. If i click (and hold) the title bar, the windows doesn''t redraw itself. What shall i do? I tried drawing when recieving WM_SIZING and WM_MOVING messages, but then it only updates when moving or resizing (still freezes if i click-and-hold the title bar). I also tried moving the drawing from the callback to the messageloop but with no success.. I''m using MSVC 6. Thankful for any help! Cheers, Simon

##### Share on other sites
You need to look for the WM_PAINT message for redrawing the window..

You also need to check out the message that triggers when the window is moved (I cannot think of it right now) i think its WM_MOVE.. not sure... check out www.msdn.microsoft.com

also try the MoveWindow function.. it may help.

##### Share on other sites
quote:
Original post by Zantac
...i''d like to use the windowstyle WS_POPUP... but when i do, i can''t move the window! I tried setting the window pos manually, but i got alot of flickering and other problems.

Don''t use WS_POPUP. Look up the various window styles and combine the ones you want. e.g.
hwnd = CreateWindowEx(WS_EX_ACCEPTFILES|WS_EX_APPFILES, WS_OVERLAPPED|WS_BORDER|WS_CLIPSIBLINGS|WS_TILED, ...);

quote:
Another problem i have is that if i''m resizing or moving a window, it simply stops updating.

As GoofProg said, handle the WM_PAINT message. if you let this fall throuhg to DefWindowProc the window will be redrawn in its existing style, but none of your controls, etc will be drawn.

##### Share on other sites
You should certainly paint the window in response to the WM_PAINT message. Another tip to avoid flickering it to override the WM_ERASEBKGND message and do nothing (just stop the default implementing from running). Then, in the WM_PAINT handler, paint the entire window, warts and all. This will produce bootyful flicker-free drawing when you size your window.

In terms of moving the window when you click on the title bar, use Spy++ to see what messages are sent to a window when you do this. I seem to remember a WM_SYSCOMMAND message gets sent when moving a window with the title bar. You need to replicate this message anyway - I''ve done it before so I know it works.

The problem with the window not redrawing itself could be due to the way you are doing something. If, in response to a message you are freezing the main thread of your application - no more messages (like WM_PAINT) will be processed. If you can provide a code snippet, that would help.

##### Share on other sites
Hi again,

thanks for your replies, but it''s not really what i was looking for. I am handling the WM_PAINT message already. The flickering occured when i tried to move the window manually, since it by default (when using style WS_POPUP) can''t be moved. The solution to my problem was to include a

SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, lparam);

when handling WM_LBUTTONDOWN.

I need to use WS_POPUP because i want to reshape the window so that it has the same shape as one of the skins i''ll be using (by defining a region). (Maybe this can be done without using WS_POPUP? Please tell me if i''m wrong) Also, because of this (the reshaping) i don''t want a border around the window.

Anyway, thanks for all your suggestions =)

Cheers,
Simon

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627638
• Total Posts
2978330

• 10
• 12
• 22
• 13
• 34