Skip to main content
gamedev.net
🔒 Locked

Win32 help needed

Started by Servant of the Lord 9 replies 1.7k views
Original Post
Servant of the Lord
Servant of the Lord
I haven't been programming win32 too long, only three or four days now, besides glancing a it once in the past, but I decided to write a 2D level editor for a (SDL) rpg I'm making, and for the most part it's coming out fine. I have a few things I would like, however, which I can't find out how to do. First, I would like to keep my main window from being resized/maximized, but still allow it to be minimized. Second, my toolbar or sidepanel isn't hooked into my main window, and when I move the window about, the panel doesn't move with it. The sidepanel also captures the focus of the screen when clicked on. This is only a minor annoyance, but how can I get it to share the focus of the main window so the main window's caption isn't grayed out whenever I click on the sidepanel? Also, I'm having trouble using these(MSDN), and would like a small example of how I might use them, if someone's willing. I don't know exactly where to use them, and I have trouble moving around MSDN. Found a example. Many thanks,
Illuminate
Illuminate
Quote:

First, I would like to keep my main window from being resized/maximized, but still allow it to be minimized.


Create your window with WS_VISIBLE|WS_SYSMENU|WS_MINIMIZEBOX style. Sorry but that is all I can help.
WS_SYSMENU include WS_CAPTION (adds caption, borders and X-button)

[Edited by - Illuminate on August 6, 2006 6:12:28 PM]
______Excited of C++Keen on C++Love C++Bulgarian Pirate :)
Servant of the Lord
Servant of the Lord
Quote:
Original post by Illuminate
Quote:

First, I would like to keep my main window from being resized/maximized, but still allow it to be minimized.


Create your window with WS_VISIBLE|WS_SYSMENU|WS_MINIMIZEBOX style. Sorry but that is all I can help.


Thanks. Should I add WS_CAPTION in there too or is that covered by one of the others?
Servant of the Lord
Servant of the Lord
I created this to keep the sidepanel at the left side of the main window, but it creates errors at runtime. Can anyone see what I'm doing wrong?

LPRECT Wcoridinates; //variable to hold the coridinatesGetWindowRect(hwnd,Wcoridinates); //coridinates of the main window (hwnd being the main window's handle)//Set the sidepanel's handle to the topleft coridinates of the main windowSetWindowPos(g_hToolbar,HWND_TOPMOST,Wcoridinates->left,Wcoridinates->top,0,0,SWP_NOSIZE);


Now, I realize that this would cause the sidepanel to overlap the caption bar, but I was planning on simpling altering it manually from there. However, I get a 'Map Editor.exe has encountered a problem and needs to close' message from Microsoft and it shuts down.

I have the code set to run whenever I get a WM_MOVE message. Any idea how I could get this to work correctly?
DanielH
DanielH
Try this:

RECT Wcoridinates; //variable to hold the coridinatesGetWindowRect(hwnd,&Wcoridinates); //coridinates of the main window (hwnd being the main window's handle)
Servant of the Lord
Servant of the Lord
Quote:
Original post by DanielH
Try this:

RECT Wcoridinates; //variable to hold the coridinatesGetWindowRect(hwnd,&Wcoridinates); //coridinates of the main window (hwnd being the main window's handle)


Many thanks, that did it. I had to adjust the final the final thing so it wouldn't be at the exact corner of the window, and this is the final thing:
RECT Wcoridinates;GetWindowRect(hwnd,&Wcoridinates);SetWindowPos(g_hToolbar,HWND_TOPMOST,(Wcoridinates.left + 5),(Wcoridinates.top + 51),0,0,SWP_NOSIZE);


Many for all your help!

The window can't be maximized or resized either, using Illuminate's code. Many thanks everyone! Whenever I move the window, the caption bar goes gray, and the toolbar has a slight lag when be dragged about, but as this is only a map editor, it's more amusing than annoying. I really apreciate the abillity to get onto gamedev and within 24 hours get help for any programming trouble I have.
Alamar
Alamar
Wow... suggestions for preventing resizing by trapping messages is a REALLY bad idea... And too much work...

You can just create the window with a border type that can't be resized... (Don't create it with WS_THICKFRAME/WS_SIZEBOX, which is included in WS_OVERLAPPEDWINDOW)

-Alamar

Topic Locked

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

Sign in to reply to this topic.