Page 1 of 2
Win32 app in C++
Posted: Fri Oct 25, 2002 10:37 am
by Kon-Tiki
[attachment deleted by admin]
Re:Win32 app in C++
Posted: Fri Oct 25, 2002 4:12 pm
by ark
Not sure I understand the question entirely. To add an item to the menu, you need to edit the resource script (the .rc file). To add a handler for when somebody selects the menu item, you need to handle the WM_COMMAND message. In the code you posted, WM_COMMAND appears to be handled by this function:
void MainWndProc_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
Re:Win32 app in C++
Posted: Fri Oct 25, 2002 4:15 pm
by Kon-Tiki
Thanks, I'll try it out and post the result.
-Kon-Tiki-
Re:Win32 app in C++
Posted: Fri Oct 25, 2002 4:19 pm
by ark
Umm...just ran this thing and it has a really funky title bar. You should probably find this code:
Code: Select all
HWND CreatewinpicWndClassWnd(void)
{
return CreateWindowEx(WS_EX_TOOLWINDOW,
"winpicWndClass","winpic",
WS_MINIMIZEBOX|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_MAXIMIZEBOX|WS_CAPTION|WS_BORDER|WS_SYSMENU|WS_THICKFRAME,
CW_USEDEFAULT,0,CW_USEDEFAULT,0,
NULL,
NULL,
hInst,
NULL);
}
and change WS_EX_TOOLWINDOW to 0.
Re:Win32 app in C++
Posted: Fri Oct 25, 2002 4:21 pm
by ark
incidentally, a lot of those window styles (like WS_BORDER) are completely unnecessary if you simply specify WS_OVERLAPPEDWINDOW
Re:Win32 app in C++
Posted: Sun Oct 27, 2002 11:58 am
by Kon-Tiki
Yippeekayey yippeekayo! It works, although my test with printf("You've clicked 'new'"); didn't work. Now all I have to do is copy and paste the pieces of code of Picedit (like Nick said) and Picedit'll be Winpic.
THANKS JOEL
-Kon-Tiki-
Re:Win32 app in C++
Posted: Sun Oct 27, 2002 12:13 pm
by Tom
You can't use printf in a Win32 App unless some strange programming is done.
You need to use MessageBox( "Msg", "Title" ...... );
printf is for consol win32 apps.
Re:Win32 app in C++
Posted: Sun Oct 27, 2002 1:18 pm
by Kon-Tiki
Guess I'll better search for the help-file then. It's being a pain in the blatter, working without it.
-Kon-Tiki-
Re:Win32 app in C++
Posted: Sun Oct 27, 2002 1:27 pm
by ark
I don't think it's going to be just a matter of cutting and pasting. I do have that pic resource C++ class which can read and draw pics from both disk files and VOL files, though.
Like Tom said, you won't use printf() in Win32 programming...if you want to print out formatted text as just a simple message, you can use sprintf() along with MessageBox(). But if you're just trying to print out "New was selected", then all you really need is MessageBox().
Something as simple as:
MessageBox(hwndMainWnd, "You've clicked 'new'.", "Menu Selection", MB_OK);
will do the trick. Of course, you'll have to replace hwndMainWnd with whatever you're calling the window handle for your main window (or you can just use NULL).
Re:Win32 app in C++
Posted: Sun Oct 27, 2002 1:44 pm
by Kon-Tiki
That printf was just to see if it really worked. Anyway, Joel: what exactly is that Pic resource class and what does it do?
-Kon-Tiki-
Re:Win32 app in C++
Posted: Sun Oct 27, 2002 5:51 pm
by ark
the pic resource class encapsulates an AGI Picture. As I said, it needs some work before it would be useful in an editor, but right now you can do something like this:
Code: Select all
HDC hdc = GetDC(hwndMainWnd);
CPicResource pic;
pic.LoadFromFile("c:\\My Game\\Picture.001");
pic.DrawPicToDC(hdc, SCR_VISUAL);
ReleaseDC(hdc);
And that would load a picture resource from the file c:\My Game\Picture.001 and also draw it on the main window. It's actually not quite as simple as all that. Although it will draw the picture, the way I've got it written now, the picture resource is drawn with square pixels...you'd have to use the StretchBlt windows API function to get the double-wide pixels like AGI uses them. I may change that, though, and provide some parameters that tell the class to stretch the picture so that code using the class wouldn't have to stretch it.
Re:Win32 app in C++
Posted: Sun Oct 27, 2002 6:52 pm
by Kon-Tiki
Tried that code. Never seen so many errors come from that project. Guess I'll have to find some way to get those 13.5Mb of helpfile onto disks (the computer I program on doesn't have any working network or cd-rom, so it has to go through disks ::) ) Maybe that'll help me even understand the commands so I can see what could be wrong with it. (Dagnabbit, it's a pain in the blatter, being a newbie
)
-Kon-Tiki-
Re:Win32 app in C++
Posted: Sun Oct 27, 2002 9:05 pm
by ark
That was just an example...that code won't compile because you don't have the class. I can post it if you want it. I went ahead and made the changes so that it will stretch to correct AGI proportions by default.
Re:Win32 app in C++
Posted: Sun Oct 27, 2002 9:31 pm
by Andrew_Baker
You go guys!!! We need WinPicEdit!
Re:Win32 app in C++
Posted: Mon Oct 28, 2002 11:31 am
by ark
[attachment deleted by admin]