| | |
Help with Win32 API Menu
Thread Solved |
I am new to Win32 API and am having trouble setting up the menu. Here is what I have at the moment (my new way of doing the main.cpp code is from another member) but I cannot understand where to put in the function call for the menu..
main.cpp
GUI.rc
resource.h
main.cpp
C Syntax (Toggle Plain Text)
#include <windows.h> #include <string> #include "resource.h" LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { switch(Msg) { case WM_INITDIALOG: // Initiate what loads when the application starts return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_LATE_BREAK_BTN: return TRUE; case IDCANCEL: EndDialog(hWndDlg, 0); return TRUE; } break; } return FALSE; } int APIENTRY WinMain (HINSTANCE hInst, HINSTANCE unused, LPSTR cmdLine, int cmdShow) { DialogBox(hInst, MAKEINTRESOURCE(IDD_CONTROLS_DLG), 0, (DLGPROC)(DlgProc)); return 0; }
GUI.rc
C Syntax (Toggle Plain Text)
#include "resource.h" #include <afxres.h> IDD_CONTROLS_DLG DIALOG DISCARDABLE 0, 0, 132, 180 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "HSBC Break Clock" FONT 8, "MS Sans Serif" BEGIN LTEXT "Current Time is: ",IDC_STATIC,10,10,55,12 LTEXT "Meeting Time: ",IDC_STATIC,10,30,45,12 LTEXT "Start Time: ",IDC_STATIC,10,50,45,12 LTEXT "Break 1 Start: ",IDC_STATIC,10,70,45,12 LTEXT "Lunch Start: ",IDC_STATIC,10,90,45,12 LTEXT "Break 2 Start: ",IDC_STATIC,10,110,45,12 LTEXT "End Time: ",IDC_STATIC,10,130,45,12 EDITTEXT IDC_CURRENT_TIME,80,10,45,12, ES_AUTOHSCROLL EDITTEXT IDC_MEETING_TIME,80,30,45,12,ES_RIGHT | ES_AUTOHSCROLL EDITTEXT IDC_START_TIME,80,50,45,12,ES_RIGHT | ES_AUTOHSCROLL EDITTEXT IDC_BREAK1,80,70,45,12,ES_RIGHT | ES_AUTOHSCROLL EDITTEXT IDC_LUNCH,80,90,45,12,ES_RIGHT | ES_AUTOHSCROLL EDITTEXT IDC_BREAK2,80,110,45,12,ES_RIGHT | ES_AUTOHSCROLL EDITTEXT IDC_LEAVE_TIME,80,130,45,12,ES_RIGHT | ES_AUTOHSCROLL PUSHBUTTON "Late Break",IDC_LATE_BREAK_BTN,20,150,40,18 PUSHBUTTON "Quit",IDCANCEL,70,150,40,18 END IDR_MAIN_MENU MENU BEGIN POPUP "&File" BEGIN MENUITEM "Se&lect a Sound", IDM_FILE_SOUND MENUITEM "E&xit", IDM_FILE_EXIT END POPUP "&Help" BEGIN MENUITEM "&About...\tF1", IDM_HELP_ABOUT END END
resource.h
C Syntax (Toggle Plain Text)
#define IDD_CONTROLS_DLG 101 #define IDR_MAIN_MENU 102 #define IDR_POPUP 103 #define IDC_CURRENT_TIME 1002 #define IDC_MEETING_TIME 1003 #define IDC_START_TIME 1004 #define IDC_BREAK1 1005 #define IDC_LUNCH 1006 #define IDC_BREAK2 1007 #define IDC_LEAVE_TIME 1008 #define IDC_LATE_BREAK_BTN 1009 #define IDM_FILE_SOUND 2001 #define IDM_FILE_EXIT 2002 #define IDM_HELP_ABOUT 2003
Error: Keyboard not attached. Press F1 to continue.
I do know everything, just not all at once. It's a virtual memory problem.
I do know everything, just not all at once. It's a virtual memory problem.
The FONT line is about the 7th line in gui.rc. Put the MENU line after that.
In that same file you can get rid of <afxres.h> if you replace IDC_STATIC with its value, -1. I believe most people do this.
In main.c, <string> should be <string.h>. If you didn't get an error, then you're compiling in C++ mode (probably with a .cpp filename). This is not necessarily a problem, but if you mean to be using C, you should compile in C mode (with a .c filename).
In that same file you can get rid of <afxres.h> if you replace IDC_STATIC with its value, -1. I believe most people do this.
In main.c, <string> should be <string.h>. If you didn't get an error, then you're compiling in C++ mode (probably with a .cpp filename). This is not necessarily a problem, but if you mean to be using C, you should compile in C mode (with a .c filename).
I am way out of date with c.. I am using Dev-C++.. And I have the settings tweaked for compiling with c++ and enabling C.
It works now.. Thanks.. After I finish this project in C I will start using C++. I am just learning Win32 API and the best tutorial i found was in C.. I just dont understand most of it yet.. I am very proficient in Java and VB and C.. Thanks again.
It works now.. Thanks.. After I finish this project in C I will start using C++. I am just learning Win32 API and the best tutorial i found was in C.. I just dont understand most of it yet.. I am very proficient in Java and VB and C.. Thanks again.
Error: Keyboard not attached. Press F1 to continue.
I do know everything, just not all at once. It's a virtual memory problem.
I do know everything, just not all at once. It's a virtual memory problem.
![]() |
Similar Threads
- Frustration with Windows API (C++)
- Creating Drive, Directory and File List Boxes inVC++ using Win32 API (C++)
- How to create a notepad in c++? (C++)
- "Generic Host Process for Win32 Services ERROR" Virus or system error?????? (Viruses, Spyware and other Nasties)
- Implement "Whats This" using Win32 (C)
- WM_SIZING Probelm in my application (C)
- CoolWWW/ (Viruses, Spyware and other Nasties)
- Can't remove "about:blank" homepage. Please help. (Viruses, Spyware and other Nasties)
Other Threads in the C Forum
- Previous Thread: Reading binary file without knowing file format
- Next Thread: Improving code functionality
| Thread Tools | Search this Thread |
adobe api array arrays binarysearch calculate char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o ide inches incrementoperators intmain() iso kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc program programming pyramidusingturboccodes read recursion recv recvblocked repetition research scanf scheduling segmentationfault send shape socketprograming socketprogramming stack standard strchr string suggestions systemcall test unix urboc user variable voidmain() wab win32api windows.h






