编写完成了一个C/C++程序,如何做一个界面出来?
展开全部
最简单的方法是用vc6新建一个Win32 Application空工程,然后添加一个cpp文件,输入
(注意添加对话框资源,并且在对话框上添加一个文本框)
#include <Windows.h>
#include "resource.h"
// DialogProc, 枚举窗口对话框过程.
int CALLBACK DialogProc( HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam){
switch(uMsg){
case WM_INITDIALOG:{
SendDlgItemMessage(hdlg,IDC_EDIT1,EM_REPLACESEL,0,(long)"文本......");
}break;
case WM_DESTROY: break;
case WM_COMMAND:
switch(LOWORD(wParam)){
case IDCANCEL:
case IDOK:{
// DestroyWindow(hdlg);
EndDialog(hdlg,0);
} break;
default: break; // switch(LOWORD(wParam))} break; // case WM_COMMAND:
} // switch(uMsg)
return false;}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE,LPSTR,int){
// HWND hDialog=CreateDialog(hInst,(LPCTSTR)IDD_DIALOG1,0L,DialogProc);
return DialogBox(hInst,(LPCTSTR)IDD_DIALOG1,0L,DialogProc);}
(注意添加对话框资源,并且在对话框上添加一个文本框)
#include <Windows.h>
#include "resource.h"
// DialogProc, 枚举窗口对话框过程.
int CALLBACK DialogProc( HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam){
switch(uMsg){
case WM_INITDIALOG:{
SendDlgItemMessage(hdlg,IDC_EDIT1,EM_REPLACESEL,0,(long)"文本......");
}break;
case WM_DESTROY: break;
case WM_COMMAND:
switch(LOWORD(wParam)){
case IDCANCEL:
case IDOK:{
// DestroyWindow(hdlg);
EndDialog(hdlg,0);
} break;
default: break; // switch(LOWORD(wParam))} break; // case WM_COMMAND:
} // switch(uMsg)
return false;}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE,LPSTR,int){
// HWND hDialog=CreateDialog(hInst,(LPCTSTR)IDD_DIALOG1,0L,DialogProc);
return DialogBox(hInst,(LPCTSTR)IDD_DIALOG1,0L,DialogProc);}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询