关于vc6上c++程序问题通过API现实资源窗体
#include"Windows.h"#include"resource.h"#include"shlobj.h"HWNDdlg;HANDLEhinst;BOOLCALL...
#include "Windows.h"
#include "resource.h"
#include "shlobj.h"
HWND dlg;
HANDLE hinst;
BOOL CALLBACK DlgProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
hinst=CreateDialog(NULL,MAKEINTRESOURCE(IDD_DIALLOG1),NULL,(DLGPROC)DlgProc);
ShowWindow(dlg,nCmdShow);
SetWindowPos(dlg,HWND_TOP,200,200,350,180,SWP_SHOWWINDOW);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return TRUE;
}
BOOL CALLBACK DlgProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
return TRUE;
case WM_RBUTTONDOWN:
POINT pt;
pt.x=LOWORD(lParam);
pt.y=HIWORD(lParam);
HMENU menu;
HMENU sub;
menu=LoadMenu((HINSTANCE)hinst,"IDR_MENU1");
sub=GetSubMenu(menu,0);
ClientToScreen(hwnd,&pt);
TrackPopupMenu(sub,TPM_LEFTALIGN|TPM_LEFTBUTTON,
pt.x,pt.y,0,hwnd,NULL);
return TRUE;
case WM_CLOSE:
Destroy Window(hwnd);
dlg=NULL;
PostQuitMessage(0);
return TRUE;
case WM_COMMAND:
switch(wParam)
{
case IDC_BUTTON1:
BROWSEINFO bi;
char buffer[MAX_PATH];
ZeroMemory(buffer,MAX_PATH);
bi.hwndOwner=hwnd;
bi.pidlRoot=NULL;
bi.pszDisplayName=buffer;
bi.lpszTitle="选择文件夹";
bi.ulFlags=BIF_EDITBOX;
bi.lpfn=NULL;
bi.lParam=0;
bi.iLmage=0;
LPITEMIDLIST pList=NULL;
if((pList = SHBrowseForfolder(&bi))!=NULL)
{
char path[MAX_PATH];
ZeroMemory(path,MAX_PATH);
SHGetPathFromIDList(pList,path);
SetWindowText(GetDlgItem(hwnd,IDC_EDIT1),path);
DlgDirList(hwnd,path,IDC_LIST2,0,DDL_READONLY|DDL_ARCHIVE|DDL_HIDDEN|DDL_READWRITE);
}
}
}
return FALSE;
}
}
运行后出现
--------------------Configuration: WinApi - Win32 Debug--------------------
Compiling...
ApiDialog.cpp
e:\c++\winapi\apidialog.cpp(2) : fatal error C1083: Cannot open include file: 'resource.h': No such file or directory
Error executing cl.exe.
WinApi.exe - 1 error(s), 0 warning(s) 展开
#include "resource.h"
#include "shlobj.h"
HWND dlg;
HANDLE hinst;
BOOL CALLBACK DlgProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
hinst=CreateDialog(NULL,MAKEINTRESOURCE(IDD_DIALLOG1),NULL,(DLGPROC)DlgProc);
ShowWindow(dlg,nCmdShow);
SetWindowPos(dlg,HWND_TOP,200,200,350,180,SWP_SHOWWINDOW);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return TRUE;
}
BOOL CALLBACK DlgProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
return TRUE;
case WM_RBUTTONDOWN:
POINT pt;
pt.x=LOWORD(lParam);
pt.y=HIWORD(lParam);
HMENU menu;
HMENU sub;
menu=LoadMenu((HINSTANCE)hinst,"IDR_MENU1");
sub=GetSubMenu(menu,0);
ClientToScreen(hwnd,&pt);
TrackPopupMenu(sub,TPM_LEFTALIGN|TPM_LEFTBUTTON,
pt.x,pt.y,0,hwnd,NULL);
return TRUE;
case WM_CLOSE:
Destroy Window(hwnd);
dlg=NULL;
PostQuitMessage(0);
return TRUE;
case WM_COMMAND:
switch(wParam)
{
case IDC_BUTTON1:
BROWSEINFO bi;
char buffer[MAX_PATH];
ZeroMemory(buffer,MAX_PATH);
bi.hwndOwner=hwnd;
bi.pidlRoot=NULL;
bi.pszDisplayName=buffer;
bi.lpszTitle="选择文件夹";
bi.ulFlags=BIF_EDITBOX;
bi.lpfn=NULL;
bi.lParam=0;
bi.iLmage=0;
LPITEMIDLIST pList=NULL;
if((pList = SHBrowseForfolder(&bi))!=NULL)
{
char path[MAX_PATH];
ZeroMemory(path,MAX_PATH);
SHGetPathFromIDList(pList,path);
SetWindowText(GetDlgItem(hwnd,IDC_EDIT1),path);
DlgDirList(hwnd,path,IDC_LIST2,0,DDL_READONLY|DDL_ARCHIVE|DDL_HIDDEN|DDL_READWRITE);
}
}
}
return FALSE;
}
}
运行后出现
--------------------Configuration: WinApi - Win32 Debug--------------------
Compiling...
ApiDialog.cpp
e:\c++\winapi\apidialog.cpp(2) : fatal error C1083: Cannot open include file: 'resource.h': No such file or directory
Error executing cl.exe.
WinApi.exe - 1 error(s), 0 warning(s) 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询