| | |
Windows gui
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2006
Posts: 2
Reputation:
Solved Threads: 0
I know this is a noob question but where do i put my own code in this menu code for windows.
Edit: Added code tags!
C Syntax (Toggle Plain Text)
#include <windows.h> /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM); /* Make the class name into a global variable */ char szClassName[ ] = "WindowsApp"; int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof(WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor(NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use light-gray as the background of the window */ wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH); /* Register the window class, if fail quit the program */ if(!RegisterClassEx(&wincl)) return 0; /* The class is registered, let's create the program*/ hwnd = CreateWindowEx( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ "Windows App", /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 544, /* The programs width */ 375, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow(hwnd, nFunsterStil); /* Run the message loop. It will run until GetMessage( ) returns 0 */ while(GetMessage(&messages, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); } /* The program return-value is 0 - The value that PostQuitMessage( ) gave */ return messages.wParam; } /* This function is called by the Windows function DispatchMessage( ) */ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) /* handle the messages */ { case WM_DESTROY: PostQuitMessage(0); /* send a WM_QUIT to the message queue */ break; default: /* for messages that we don't deal with */ return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }
Last edited by vegaseat; Mar 2nd, 2006 at 12:25 pm.
start at the beginning, not somewhere in the middle of things.Here is a good tutorial to get you started.
Generally, you create your window and other controls in WinMain() after the call to RegisterClass() and before the start of the event loop. I prefer to put these things into their own functions to make things more readable. Anything related to an actual response to an event goes into CALLBACK WndProc(). Again, once you have indicated the event, you can call your own response functions.
Read the tutorial (somewhat ancient) recommended by AncientDragon. Also look at some of the simple GUI code snippets here on DaniWeb. For instance:
http://www.daniweb.com/code/snippet96.html
Read the tutorial (somewhat ancient) recommended by AncientDragon. Also look at some of the simple GUI code snippets here on DaniWeb. For instance:
http://www.daniweb.com/code/snippet96.html
May 'the Google' be with you!
nothing wrong with old tutorials, they teach the core instead of getting sidetracked into fancy new additions...
Why include XP skinning into a tutorial teaching introductory Win32 programming for example...
Why include XP skinning into a tutorial teaching introductory Win32 programming for example...
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Why do folks assume that old is bad?
The win GUI tutorial at http://www.winprog.org/tutorial/ is great! There is a heck of a learning curve, mostly because the underlying API was written by MS and includes the kitchen sink. Not a fault of the tutorial.
Once you can make yourself a mental picture of the parts and figure out how they are connected you are 10% there!
The win GUI tutorial at http://www.winprog.org/tutorial/ is great! There is a heck of a learning curve, mostly because the underlying API was written by MS and includes the kitchen sink. Not a fault of the tutorial.
Once you can make yourself a mental picture of the parts and figure out how they are connected you are 10% there!
May 'the Google' be with you!
![]() |
Similar Threads
- Best language for programming in windows (Computer Science)
- Windows GUI - problem with dialog box (C++)
- Windows vs Mac (Geeks' Lounge)
- Tkinter Windows - How not to destroy it? (Python)
- ?A Simple Win32 GUI Introduction Snippet? (C++)
- A request for information on Windows programming in C (C++)
- Bypassing Welcome screen in XP (Windows NT / 2000 / XP)
Other Threads in the C Forum
- Previous Thread: Need immediate help ( Challenging software )
- Next Thread: accessing bmps in C
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays asterisks binarysearch calculate changingto char character cm command copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fgets file fork forloop framework function functions givemetehcodez grade graphics gtkwinlinux hacking histogram homework include incrementoperators input intmain() iso kernel keyboard km lazy license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number oddnumber odf opensource overwrite owf pdf performance pointer posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket socketprograming spoonfeeding standard string student systemcall testing threads turboc unix user variable wab whythiscodecausesegmentationfault windowsapi






