VoyForums
[ Show ]
Support VoyForums
[ Shrink ]
VoyForums Announcement: Programming and providing support for this service has been a labor of love since 1997. We are one of the few services online who values our users' privacy, and have never sold your information. We have even fought hard to defend your privacy in legal cases; however, we've done it with almost no financial support -- paying out of pocket to continue providing the service. Due to the issues imposed on us by advertisers, we also stopped hosting most ads on the forums many years ago. We hope you appreciate our efforts.

Show your support by donating any amount. (Note: We are still technically a for-profit company, so your contribution is not tax-deductible.) PayPal Acct: Feedback:

Donate to VoyForums (PayPal):

Login ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: [1] ]


[ Next Thread | Previous Thread | Next Message | Previous Message ]

Date Posted: 10:38:43 11/07/05 Mon
Author: wiccan_two
Subject: c++ win32 program

i need help with my program i am learning win32 using c++ but i cant get my mennus to do any thing, the program is a blank window wit custom cursor, custom icon, and a menu with file - exit, and help - about. the first thing i tried to do is make the file - exit work but with no success so i havnt tried help - about yet.

here is the code.

resources.h

#define IDC_AROW1 1000
#define IDI_ICON1 1001
#define IDM_MENU 1002
#define IDM_FILE_EXIT 1003
#define IDM_HELP_ABOUT 1004


resorces.rc


#include "Resources.h"

IDC_AROW1 CURSOR "larrow.cur"
IDI_ICON1 ICON "wt.ico"
IDM_MENU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", IDM_FILE_EXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About", IDM_HELP_ABOUT
END
END


main.cpp


//---------------------------------------------------------------------------
#include
#include "Resources.h"
#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
//---------------------------------------------------------------------------
const char *ClsName = "FundApp";
const char *WndName = "My First Win32 App";
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 application window
WndClsEx.cbSize = sizeof(WNDCLASSEX);
WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc = WndProcedure;
WndClsEx.cbClsExtra = 0;
WndClsEx.cbWndExtra = 0;
WndClsEx.hIcon = LoadIcon(hInstance,
MAKEINTRESOURCE(IDI_ICON1));
WndClsEx.hCursor = LoadCursor(hInstance,
MAKEINTRESOURCE(IDC_AROW1));
WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClsEx.lpszMenuName = "IDM_MENU";
WndClsEx.lpszClassName = ClsName;
WndClsEx.hInstance = hInstance;
WndClsEx.hIconSm = LoadIcon(hInstance,
MAKEINTRESOURCE(IDI_ICON1));

// Register the application
RegisterClassEx(&WndClsEx);

// Create the window object
hWnd = CreateWindowEx(0,
ClsName,
WndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);

// Find out if the window was created
if( !hWnd ) // If the window was not created,
return FALSE; // stop the application

// Display the window to the user
ShowWindow(hWnd, nCmdShow);// SW_SHOWNORMAL);
UpdateWindow(hWnd);

// Decode and treat the messages
// as long as the application is running
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 IDM_FILE_EXIT:
return 0;
break;
default:
// Process the left-over messages
return DefWindowProc(hWnd, Msg, wParam, lParam);
}




//---------------------------------------------------------------------------
// If something was not done, let it go
return 0;
}
//---------------------------------------------------------------------------



email me if you want a zip of all the file
please help i cant figure this one out

[ Next Thread | Previous Thread | Next Message | Previous Message ]

[ Contact Forum Admin ]


Forum timezone: GMT-8
VF Version: 3.00b, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2019 Voyager Info-Systems. All Rights Reserved.