Jump to content
  • Advertisement
Sign in to follow this  
Gor435

I HATE WIN32 I HATE IT I HATE IT(Major part solved)

This topic is 5018 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am having a problem here i have used the forger win32 api tutorial and some others but i cant figure out what i am doing wrong i can seem to get my resource files to work with my .cpp files and i cant even get my windows menus to work right nor can i get the icons to display right nor can i get rid of that annoying little console window that displays with my window oh and btw im poor so i use dev-c++ does this about sum it up here lets try some code to be sure this is what i have
#include <windows.h>

#define ID_FILE_EXIT 1000

const char *ClsName = "BasicApp";
const char *WndName = "HI";

LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

{       
        MSG Msg;    
        HWND hWnd;
        WNDCLASSEX WndClsEx;
        
        // Create the app window
        WndClsEx.cbSize = sizeof (WNDCLASSEX);
        WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
        WndClsEx.lpfnWndProc = WndProcedure;
        WndClsEx.cbClsExtra = 0;
        WndClsEx.cbWndExtra = 5;
        WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
        WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
        WndClsEx.hInstance = hInstance;
        WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW);
        WndClsEx.hbrBackground = (HBRUSH)(21); //(HBRUSH) GetStockObject (COLOR_WINDOW);
        WndClsEx.lpszMenuName = NULL;
        WndClsEx.lpszClassName = ClsName;
       
        // register 
       RegisterClassEx(&WndClsEx);
        
        // Create the window object
      hWnd = CreateWindow(ClsName,
			  WndName,
			  WS_OVERLAPPEDWINDOW,
			  CW_USEDEFAULT,
			  CW_USEDEFAULT,
			  CW_USEDEFAULT,
			  CW_USEDEFAULT,
			  NULL,
			  NULL,
			  hInstance,
			  NULL);
       
       if(!hWnd)
       return 0;
       
       ShowWindow(hWnd, SW_SHOWNORMAL);
       UpdateWindow(hWnd);
       
       while( GetMessage(&Msg, NULL, 0, 0))
       {
               TranslateMessage(&Msg);
               DispatchMessage(&Msg);   
       }
       
             
       return Msg.wParam;
       
    }
    
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
        switch(Msg)
        {
            case WM_CREATE:
                {
                 HMENU hMenu, hSubMenu;
                 
                 hMenu = CreateMenu();
                 
                 hSubMenu = CreatePopupMenu();
                 
                 AppendMenu(hSubMenu, 2, ID_FILE_EXIT, "E&xit");
                 AppendMenu(hMenu, 2, (UINT)hSubMenu,"&File");
                 
                 SetMenu(hWnd, hMenu);
               
                }
                break;    
            case WM_DESTROY:
                PostQuitMessage(WM_QUIT);
                break;
            default:
                return DefWindowProc(hWnd, Msg, wParam, lParam);
            }
            return 0;
        }



the problem here is the fact that the program works fine exept i cant seem to get my exit command to show i click file and well nothing happens Thank you Palidine. ok but still need help with win32 [Edited by - Gor435 on January 19, 2005 10:16:27 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:

apparently <source></source> doesnt work like everyone tells me it does blah!!


that's b/c it's [ and ] not < and >

-me

Share this post


Link to post
Share on other sites
Add WM_COMMAND case to your switch block.


...
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILE_EXIT:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
break;
...



Share this post


Link to post
Share on other sites
and that does absolutly nothing the program runs just the same i still have no exit nothing happens when i click file notta :/

BTW how do these people expect you to learn this stuff when they rarley explain why you need to type some of this stuff

i mean they say IDD_ABOUTDLG is the id of the resource (example word for word from a tutorial forgers to be exact) but wtf does that mean i mean come on people

Share this post


Link to post
Share on other sites
no i dont want to forgo the api and this is not inteneded to be a game accually i want to write this program to extract .rar files (my gf plays the sims 2 and downloads mods which are usually in .rar format) i could write this program in the console but well that would just be crappy now wouldnt it

Share this post


Link to post
Share on other sites
use WTL, or MFC if you have Codewarrior/Borland C++ Builder or Visual C++
its easier.

better yet, just write it in Visual Basic or Delphi and use the UnRar.dll

Share this post


Link to post
Share on other sites
For the Win32 API there was a good book "Windows 98 Programming from the Ground Up" by Herbert Schildt.

I would not recommend to MFC to anyone I did not loathe.

.NET however is very nice, and easier to learn than either of the other options.

But if you don't want .NET then you have pure Win32 API (not done often anymore), ATL/WTL (Active Template Lirbary, Window(s) Template Library?), or the Borland VCL (Visual Class Library) system (which used to be VERY nice compared to MFC) used by Borland C++ Builder.

Share this post


Link to post
Share on other sites
I think I've caught your problem. You pass a plain 2 as a second parameter of the AppendMenu function. That corresponds to macro mnemonic MF_DISABLED. This prevents your menu from appearing. You should pass MF_POPUP instead (or 0x10 which is the same).

Anyway your program won't exit on pressing exit if you don't tell it how to respond on ID_FILE_EXIT message. Which is adding WM_COMMAND branch to switch statement.

Hope this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by Decibit
I think I've caught your problem. You pass a plain 2 as a second parameter of the AppendMenu function. That corresponds to macro mnemonic MF_DISABLED. This prevents your menu from appearing. You should pass MF_POPUP instead (or 0x10 which is the same).


sorry to be a spoil sport but the 2 there is what i put after i tried that :(
2 accually enables the menu.

Quote:
Anyway your program won't exit on pressing exit if you don't tell it how to respond on ID_FILE_EXIT message. Which is adding WM_COMMAND branch to switch statement.


ok i already have added the WM_COMMAND to my switch statement

Quote:
and that does absolutly nothing the program runs just the same i still have no exit nothing happens when i click file notta :/


next

Quote:
For the Win32 API there was a good book "Windows 98 Programming from the Ground Up" by Herbert Schildt.

I would not recommend to MFC to anyone I did not loathe.

.NET however is very nice, and easier to learn than either of the other options.

But if you don't want .NET then you have pure Win32 API (not done often anymore), ATL/WTL (Active Template Lirbary, Window(s) Template Library?), or the Borland VCL (Visual Class Library) system (which used to be VERY nice compared to MFC) used by Borland C++ Builder.


Again
Quote:
oh and btw im poor so i use dev-c++


Quote:
use WTL, or MFC if you have Codewarrior/Borland C++ Builder or Visual C++
its easier.

better yet, just write it in Visual Basic or Delphi and use the UnRar.dll


Again
Quote:
oh and btw im poor so i use dev-c++

and i have the UnRar.dll that is accually what i was try to use.
but its not like it matters now the header files that came with UnRar.dll
dont work right with dev-c++ i come up with mulitiple linker errors like (Undefinded reference to RAROpenArchive@4 and RARProcessFile@16) so i give up but still i would like to know how to fix the menu and icon problem for future reference.



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!