Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The following code sample shows how to call the common dialog boxes on a Windows Mobile-based Pocket PC.
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
LRESULT lResult = TRUE;
TCHAR szFile[MAX_PATH] = TEXT("\0");
OPENFILENAME ofn;
memset( &(ofn), 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = MAX_PATH;
switch(msg)
{
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wp, lp))
{
case IDM_OPENPRJ:
ofn.lpstrTitle = TEXT("Open Folder");
// Open project dialog for Pocket PC.
ofn.Flags = OFN_PROJECT;
if (GetOpenFileName(&ofn))
MessageBox(NULL, ofn.lpstrFile, TEXT("Info"), MB_OK);
// Add the opening project code here.
break;
case IDM_OPENFILE:
ofn.lpstrFilter = TEXT("All (*.*)\0*.*\0");
ofn.lpstrTitle = TEXT("Open File");
ofn.Flags = OFN_EXPLORER;
if (GetOpenFileName(&ofn))
MessageBox(NULL, ofn.lpstrFile, TEXT("Info"), MB_OK);
// Add the opening file code here.
break;
case IDM_SAVEFILE:
ofn.lpstrFilter = TEXT("Text (*.txt)\0*.txt\0");
ofn.lpstrTitle = TEXT("Save File As");
ofn.Flags = OFN_HIDEREADONLY;
ofn.lpstrDefExt = TEXT("txt");
if (GetSaveFileName(&ofn))
MessageBox(NULL, ofn.lpstrFile, TEXT("Info"), MB_OK);
// Add saving file code here.
break;
case IDM_PROPERTY:
// Use GetOpenFileName to choose a file, and then use
// GetSaveFileName to display its properties.
ofn.lpstrFilter = TEXT("All (*.*)\0*.*\0");
ofn.lpstrTitle = TEXT("File Property");
ofn.Flags = OFN_EXPLORER;
if (GetOpenFileName(&ofn)) {
ofn.lpstrTitle = TEXT("Property");
// Open property dialog for Pocket PC.
ofn.Flags = OFN_PROPERTY;
GetSaveFileName(&ofn);
}
break;
default:
return DefWindowProc(hwnd, msg, wp, lp);
}
break;
See Also
Designing Full-Screen Dialog Boxes | How to: Enable System-Defined File Dialog Boxes | How to: Prevent Display of Smart Minimize and OK Buttons in Dialog Boxes
Send Feedback on this topic to the authors