




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to super-classing in windows programming, where a new class is defined to add functionality to a predefined window class. The text also covers the graphics device interface (gdi) and the process of outputting text in a window's client area. Additionally, the document explains the concept of device contexts and the steps involved in printing a text string.
Typology: Slides
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















Super-classing
DLGPROC oldWindowProc; // Global variable WNDCLASS wndClass; GetClassInfo(hInstance, “BUTTON”, &wndClass); WndClss.hInstance = hInstance; wndClass.lpszClassName = “BEEPBUTTON”; OldWindowProc = wndClas.lpfnWndProc; wndClas.lpfnWndProc = myWindowProc; RegisterClass( &wndClass ); hWnd = CreateWindow(“BEEPBUTTON", "Virtual University",WS_VISIBLE | WS_OVERLAPPEDWINDOW, 50, 50, 200, 100, NULL, NULL, hInstance, NULL); oldWindowProc = (WNDPROC)SetWindowLong(hWnd, GWL_WNDPROC,(LONG)myWindowProc); while(GetMessage(&msg, NULL, 0, 0) > 0) { if(msg.message == WM_LBUTTONUP) DispatchMessage(&msg); } return msg.wParam;
Super-classing
LRESULT CALLBACK myWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_LBUTTONDOWN: MessageBeep(0xFFFFFFFF); default: return CallWindowProc(oldWindowProc, hWnd, message, wParam, lParam); } return 0; }
A GDI structure containing information that governs the display of text and graphics on a particular output device. A device context stores, retrieves, and modifies the attributes of graphic objects and specifies graphic modes. The graphic objects stored in a device context include a pen for line drawing, a brush for painting and filling, a font for text output, a bitmap for copying or scrolling, a palette for defining the available colors, and a region for clipping.
WM_PAINT message. HDC BeginPaint( HWND hwnd, // handle to window LPPAINTSTRUCT lpPaint // paint information );