[强]VC 6.0 可以这样创建对话框

本文提供了一个使用Windows API创建简单对话框的示例代码。该代码展示了如何定义对话框模板、加载资源以及处理对话框消息。通过这个例子,读者可以了解到如何在Windows应用程序中实现基本的对话框功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

// 看看代码吧
#include "stdafx.h"
#include "resource.h"
#include <windows.h>

static unsigned char dlg_14[] =
{
    0xc0,0x20,0xc8,0x80,0x00,0x00,0x00,0x00,
    0x04,0x00,0x00,0x00,0x00,0x00,0xb4,0x00,0x39,
    0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x6f,
    0x00,0x74,0x00,0x6f,0x00,0x20,0x00,0x6c,
    0x00,0x69,0x00,0x6e,0x00,0x65,0x00,0x00,
    0x00,0x08,0x00,0x4d,0x00,0x53,0x00,0x20,
    0x00,0x53,0x00,0x68,0x00,0x65,0x00,0x6c,
    0x00,0x6c,0x00,0x20,0x00,0x44,0x00,0x6c,
    0x00,0x67,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x02,0x50,0x00,0x00,0x00,0x00,0x07,
    0x00,0x09,0x00,0x32,0x00,0x0a,0x00,0xb0,
    0x04,0xff,0xff,0x82,0x00,0x26,0x00,0x4c,
    0x00,0x69,0x00,0x6e,0x00,0x65,0x00,0x20,
    0x00,0x4e,0x00,0x75,0x00,0x6d,0x00,0x62,
    0x00,0x65,0x00,0x72,0x00,0x3a,0x00,0x00,
    0x00,0x00,0x00,0x80,0x00,0x81,0x50,0x00,
    0x00,0x00,0x00,0x37,0x00,0x07,0x00,0x39,
    0x00,0x0c,0x00,0x02,0x01,0xff,0xff,0x81,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
    0x00,0x01,0x50,0x00,0x00,0x00,0x00,0x07,
    0x00,0x22,0x00,0x32,0x00,0x0e,0x00,0x01,
    0x00,0xff,0xff,0x80,0x00,0x4f,0x00,0x4b,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x01,0x50,0x00,0x00,0x00,0x00,0x4e,
    0x00,0x22,0x00,0x32,0x00,0x0e,0x00,0x02,
    0x00,0xff,0xff,0x80,0x00,0x43,0x00,0x61,
    0x00,0x6e,0x00,0x63,0x00,0x65,0x00,0x6c,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

LRESULT CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int main(int argc, char* argv[])
{
 HMODULE hModule = ::GetModuleHandle(NULL);
 HINSTANCE hInst = hModule;
 HRSRC hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(IDD_DIALOG1), RT_DIALOG);
 HGLOBAL hGlobal = ::LoadResource(hModule, hRsrc);
 DialogBoxIndirectParam(hInst, (LPCDLGTEMPLATE)dlg_14, NULL, (DLGPROC)DlgProc, NULL);
 return 0;
}

LRESULT CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
 switch(uMsg)
 {
 case WM_CLOSE:
  ::EndDialog(hDlg, IDOK);
  return TRUE;
  break;
 }
 return 0;

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值