dialog.h

来自「Windows 图形编程 书籍」· C头文件 代码 · 共 75 行

H
75
字号
#pragma once

//-----------------------------------------------------------------------------------//
//              Windows Graphics Programming: Win32 GDI and DirectDraw               //
//                             ISBN  0-13-086985-6                                   //
//                                                                                   //
//  Written            by  Yuan, Feng                             www.fengyuan.com   //
//  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
//  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
//                                                                                   //
//  FileName   : dialog.h						                                     //
//  Description: Dialog box wrapper class                                            //
//  Version    : 1.00.000, May 31, 2000                                              //
//-----------------------------------------------------------------------------------//

class KDialog
{
    virtual BOOL OnInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
	{
		m_hWnd = hWnd;
		
		return TRUE;
	}
	
	virtual BOOL OnCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
	{
		return FALSE;
	}
    
    virtual BOOL DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	switch (uMsg)
	    {
		    case WM_INITDIALOG:
			    return OnInitDialog(hWnd, wParam, lParam);

		    case WM_COMMAND:
			    return OnCommand(hWnd, wParam, lParam);
	    }

	    return FALSE;
    }

protected:	
    
	typedef enum { CDIALOG_MARKER = 31415927 };
    
	typedef struct
    {
        unsigned marker;
        KDialog * pDialog;
    } _DialogCreateRecord;
    
    static BOOL CALLBACK DialogProc(HWND hWnd,  UINT uMsg, WPARAM wParam, LPARAM lParam);

public:
	
	HWND   m_hWnd;
	
	KDialog()
	{
		m_hWnd = NULL;
	}

    int Dialogbox(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent = NULL)
    {
        _DialogCreateRecord ccr;

        ccr.marker  = CDIALOG_MARKER;
        ccr.pDialog = this;

		return ::DialogBoxParam(hInstance, lpTemplate, hWndParent, DialogProc, (LPARAM) & ccr);
    }
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?