Win 32 Windows Jim Fawcett CSE 681 SW

  • Slides: 19
Download presentation
Win 32 Windows Jim Fawcett CSE 681 – SW Modeling & Analysis Fall 2011

Win 32 Windows Jim Fawcett CSE 681 – SW Modeling & Analysis Fall 2011

Topics n References n Introduction n Simplest Win 32 Windows Program n Structure of

Topics n References n Introduction n Simplest Win 32 Windows Program n Structure of Windows Application n Controls n Dialogs

References n n n n n Catch 22 Tutorials Win. Prog Windows_Programming Orphan Tutorial

References n n n n n Catch 22 Tutorials Win. Prog Windows_Programming Orphan Tutorial Simple Windows Code Fragments Subclassing Windows and Messages Dialogs Controls n n User Controls Common Controls n Windows Shell n Browser Control

Windows Event Processing

Windows Event Processing

The Simplest Classical Windows Program n Output from the MINWIN program is shown on

The Simplest Classical Windows Program n Output from the MINWIN program is shown on the next slide. The program: n n n Creates a frame window Paints a fixed text message in the window Reacts to left mouse button clicks by creating a Message. Box n You will find the program code, minwin. cpp, and project solution, minwin. sln in the folder MINWIN. www. ecs. syr. edu/faculty/fawcett/handouts/Core. Technologies/Wi ndows. Programming/code/basic. Windows/Minwin

Structure of a Win 32 Windows Program

Structure of a Win 32 Windows Program

Data Types Windows Type Equivalent LPVOID void* LPSTR wchar_t* TCHAR char or wchar_t LPTSTR

Data Types Windows Type Equivalent LPVOID void* LPSTR wchar_t* TCHAR char or wchar_t LPTSTR char* or wchar_t* DWORD unsigned 32 bit integer WORD unsigned 16 bit integer HANDLE Windows handle HINSTANCE Handle to program instance HMENU Menu handle WPARAM 16 bit parameter LPARAM 32 bit parameter

Controls Control Library Comments User Controls Windows. h User 32. dll Child window Common

Controls Control Library Comments User Controls Windows. h User 32. dll Child window Common Controls Windows. h Comm. Ctl. dll COM based Browser Control MSHTML. h SHDOCVW. dll MSHTML. dll COM based Common Dialogs Commdlg. h Comdlg 32. dll COM based

User Controls n User controls are: n Button, Combo. Box, Edit, List. Box, Rich.

User Controls n User controls are: n Button, Combo. Box, Edit, List. Box, Rich. Edit_Class, Scrollbar, Static n Most used messages sent to control: n WM_GETTEXT, WM_GETTEXTLENGTH, WM_SETTEXT, WM_SETFONT, WM_SETFOCUS, WM_KILLFOCUS n Notifications – messages sent by control to parent: n WM_COMMAND n LPARAM handle to control window n WPARAM § HIWORD(w. Param): control-defined notification code § LOWORD(w. Param): control Identifier

Common Controls n Common Controls are: n Animation, Buttons, Calendar, Combo. Boxes, Date and

Common Controls n Common Controls are: n Animation, Buttons, Calendar, Combo. Boxes, Date and Time Picker, Drag List Boxes, Flat Scroll Bars, Image List, IP Address, List Boxes, List. View, Progress Bar, Property Sheets, Rebar, Rich Edit, Scroll Bars, Status Bars, Toolbar, Tool. Tip, Trackbar, Tree. View, Up. Down n Messages: WM_NOTIFY, … n Notifications: NM_CHAR, NM_CLICK, …

Dialogs n Dialogs come in two flavors: n Modal Dialogs n n Has own

Dialogs n Dialogs come in two flavors: n Modal Dialogs n n Has own message loop and service thread Does not relinquish focus until closed Results are retrieved at closure Non-Modal Dialogs n n Runs on parent’s thread Provides callback function for interaction with parent Does not hold onto focus Results may be retrieved while dialog is open

Frames n Frame Window: n Has canvas that covers most of the window, called

Frames n Frame Window: n Has canvas that covers most of the window, called the client area: n Canvas typically used for drawing and text, but can host controls as well. n Designer has to provide all hosting infrastructure at each control site on canvas. n Frame supports menus, toolbars, and status bars. n Can host Dialogs, created by menu clicks. n Visual Studio provides resource editors for menus and dialogs, even for Win 32 applications. n Windows Functions

Common Dialogs n Common Dialogs are: n Color, Find, Font, Open. File, Page. Setup,

Common Dialogs n Common Dialogs are: n Color, Find, Font, Open. File, Page. Setup, Print. Property. Sheet, Replace, Save. File n Messages n Notifications

End of Presentation

End of Presentation