高分求高手写一个不用mfc,写一个保存路径的对话框

caiyan807 2009-07-14 04:17:45
rt
...全文
122 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
积极的猫咪 2009-07-27
  • 打赏
  • 举报
回复
无聊
f22fbi 2009-07-19
  • 打赏
  • 举报
回复
MSDN:CreateDialog函数
drysea 2009-07-19
  • 打赏
  • 举报
回复
用WINAPI、WPF、SILVERLIGHT、JS、C#.net等等实现的算不算?MFC过时了……
yangyunzhao 2009-07-19
  • 打赏
  • 举报
回复
用QT算不算?
expter 2009-07-14
  • 打赏
  • 举报
回复
WIN32 ?
lijiawlm 2009-07-14
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 jindan_jinming 的回复:]
找到MFC中CreateDialog函数的具体实现,把那大段代码拿来主义!
这样算不算是不通过MFC实现?

[/Quote]

不算 !!
jekyli 2009-07-14
  • 打赏
  • 举报
回复
上面已经有人给代码了啊
gkimitfk 2009-07-14
  • 打赏
  • 举报
回复
TMD 我看不懂
hurryboylqs 2009-07-14
  • 打赏
  • 举报
回复
楼上的都给你代码了
还不明白?难道要从1010写起么?
caiyan807 2009-07-14
  • 打赏
  • 举报
回复
再次强调,不要用到mfc库啊
  • 打赏
  • 举报
回复
顶!
  • 打赏
  • 举报
回复
找到MFC中CreateDialog函数的具体实现,把那大段代码拿来主义!
这样算不算是不通过MFC实现?
god_sun 2009-07-14
  • 打赏
  • 举报
回复

CreateDialog (
hInst,
MAKEINTRESOURCE(IDD_DIALOG_MSG),
GetDesktopWindow(),//hWnd,
(DLGPROC) Test
);

LRESULT CALLBACK GoToMsg (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
RECT rrect;


switch (message)
{
case CREATE_ITEM:
{
HWND hEdit1, hEdit2, hButton1, hButton2;

usetmp = (_DMSUSER *)lParam;
GetWindowRect (hDlg, &rrect);
hButton2 = CreateWindow (TEXT("BUTTON"),
TEXT(""),
WS_CHILD | WS_VISIBLE,
10,
2 *(rrect.bottom - rrect.top) / 3 + 10,
20,
20,
hDlg,
(HMENU)1004,
NULL,
NULL);

usetmp->hmsgedit = hEdit1;
usetmp->hsendedit = hEdit2;
usetmp->hsendbutton = hButton1;
usetmp->hfilebutton = hButton2;

RegisterHotKey (usetmp->hwnd, 1003, MOD_CONTROL, 13);//MOD_CONTROL
SetWindowText (usetmp->hwnd, usetmp->sessoin->name);
break;
}
case WM_SIZE:
{
usetmp = clsdmsuser.stGetUser (hDlg);

GetWindowRect (hDlg, &rrect);
SetWindowPos (usetmp->hmsgedit, HWND_NOTOPMOST, 0, 10, rrect.right - rrect.left - 10,
2 * (rrect.bottom - rrect.top) / 3, SWP_NOMOVE | SWP_NOZORDER );

SetWindowPos (usetmp->hsendedit, HWND_NOTOPMOST, 0, 2 * (rrect.bottom - rrect.top) / 3 + 30,
rrect.right - rrect.left - 70, (rrect.bottom - rrect.top) / 3 - 70,
SWP_NOZORDER );

SetWindowPos (usetmp->hsendbutton, HWND_NOTOPMOST, rrect.right - rrect.left - 60,
2 * (rrect.bottom - rrect.top) / 3 + 40,
50,
(rrect.bottom - rrect.top) / 3 - 90,
SWP_NOZORDER );

SetWindowPos (usetmp->hfilebutton, HWND_NOTOPMOST, 10,
2 * (rrect.bottom - rrect.top) / 3 + 10,
20,
20,
SWP_NOZORDER );
break;
}
case WM_INITDIALOG:
{
return TRUE;
}
case WM_HOTKEY:
{
wmId = LOWORD(wParam);
if (wmId == 1003)
{
usetmp = clsdmsuser.stGetUser (GetActiveWindow ());
if (usetmp)
{
SendMessage (usetmp->hwnd, WM_COMMAND, 1003, 0);
}
}
break;
}
case WM_SYSCOMMAND:
{
if (wParam == SC_MINIMIZE)
{
ShowWindow (hDlg, SW_SHOWMINIMIZED);
}
else if (wParam == SC_RESTORE)
{
usetmp = clsdmsuser.stGetUser (hDlg);
if (usetmp)
{
ShowWindow (usetmp->hwnd, SW_RESTORE);
SetFocus (usetmp->hsendedit);
}
}
break;
}
case WM_COMMAND:
{
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);

switch (wmId)
{
case IDCANCEL:
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
case 1004:
{
usetmp = clsdmsuser.stGetUser (hDlg);
if (!usetmp) break;

OPENFILENAME ofn ;
TCHAR szFilter[] = TEXT ("Text Files (*.TXT)\0*.txt\0") \
TEXT ("ASCII Files (*.ASC)\0*.asc\0") \
TEXT ("All Files (*.*)\0*.*\0\0") ;
ofn.lStructSize = sizeof (OPENFILENAME) ;
ofn.hwndOwner = hDlg ;
ofn.hInstance = NULL ;
ofn.lpstrFilter = szFilter ;
ofn.lpstrCustomFilter = NULL ;
ofn.nMaxCustFilter = 0 ;
ofn.nFilterIndex = 1 ;
ofn.nMaxFile = MAX_PATH ;
ofn.lpstrFileTitle = NULL ; // Set in Open and Close functions
ofn.nMaxFileTitle = MAX_PATH ;
ofn.lpstrInitialDir = NULL ;
ofn.lpstrTitle = NULL ;
ofn.nFileOffset = 0 ;
ofn.nFileExtension = 0 ;
ofn.lpstrDefExt = TEXT ("txt") ;
ofn.lCustData = 0L ;
ofn.lpfnHook = NULL ;
ofn.lpTemplateName = NULL ;

ofn.lpstrFile = usetmp->filepath;
ofn.lpstrFile[0] = '\0';
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ;

if (GetOpenFileName (&ofn))
{

}
break;
}
}
break;
}
}
return FALSE;
}


hurryboylqs 2009-07-14
  • 打赏
  • 举报
回复
自己写好了
oysoft 2009-07-14
  • 打赏
  • 举报
回复
使用WTL可以吗?

class CMyDlg: public CDialogImpl<CMyDlg>
{
...
}
erwin1984 2009-07-14
  • 打赏
  • 举报
回复
MFC也是用 Windows API实现的,用API GetOpenFileName or GetSaveFileName 就可以了。

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧