Every Day's Gain

Larry.Zhao's Coding Diary
随笔 - 23, 文章 - 1, 评论 - 2, 引用 - 0
数据加载中……

获得窗体的实例句柄

共有三种方式:
1、声明一个全局的hInst变量,在WinMain里面hInst = hInstance
2、((LPCREATESTRUCT)lParam)->hInstance,通过CREATESTRUCT结构获得
3、hInst = GetWindowLong (hwnd, GWL_HINSTANCE);

ps: CREATESTRUCT结构包含了窗体创建初始化时的各种信息:

typedef struct tagCREATESTRUCT { 
    LPVOID    lpCreateParams;
    HINSTANCE hInstance;
    HMENU     hMenu;
    HWND      hwndParent;
    int       cy;
    int       cx;
    int       y;
    int       x;
    LONG      style;
    LPCTSTR   lpszName;
    LPCTSTR   lpszClass;
    DWORD     dwExStyle;
} CREATESTRUCT;

posted on 2005-07-18 23:57 Larry.Zhao's Coding Diary 阅读(775) 评论(0)  编辑 收藏 引用 所属分类: Windows App Programing

只有注册用户登录后才能发表评论。