示例#1
0
static UINT_PTR APIENTRY	// Hook for open or save file dialogs.
OpenOrSaveFileNameHook(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{	
	HWND hMainDlg;
	
	/*	Because we use the OFN_EXPLORER flag and we specify a hook function, Windows
		creates a child dialog for us and the hdlg parameter to this hook is the child
		dialog.
	*/
	hMainDlg = GetParent(hdlg);
	if (hMainDlg == NULL)
		return 0;

	switch(uiMsg) {
		case WM_INITDIALOG:
			/*	HR, 090121, XOPSupport 5.09: Because we now use OFN_ENABLESIZING, the OS positions
				sizes the dialog. However, without this hook, the dialog initially comes up in the top/left
				corner of the frame window. Therefore I decided to leave the hook in. After this hook
				positions the window, the OS repositions and resizes it which may cause a brief flash.
			*/
			PositionWinDialogWindow(hMainDlg, NULL);
			break;
	}
	return 0;			// Let default dialog box procedure process the message.
}
示例#2
0
static INT_PTR CALLBACK
DialogProc(HWND theDialog, UINT msgCode, WPARAM wParam, LPARAM lParam)
{
	int itemID, notificationMessage;
	BOOL result; 						// Function result

	static DialogStoragePtr dsp;

	result = FALSE;
	itemID = LOWORD(wParam);						// Item, control, or accelerator identifier.
	notificationMessage = HIWORD(wParam);
	
	switch(msgCode) {
		case WM_INITDIALOG:
			// Position nicely relative to the main dialog.
			PositionWinDialogWindow(theDialog, GetNextWindow(theDialog, GW_HWNDNEXT));
			
			dsp = (DialogStoragePtr)lParam;
			if (InitDialogSettings(theDialog, dsp) != 0) {
				EndDialog(theDialog, IDCANCEL);				// Should never happen.
				return FALSE;
			}

			SetFocus(GetDlgItem(theDialog, SCALING_OFFSET_TEXT));
			result = FALSE; // Tell Windows not to set the input focus			
			break;
		
		case WM_COMMAND:
			switch(itemID) {
				case OK_BUTTON:
				case CANCEL_BUTTON:
					HandleItemHit(theDialog, itemID, dsp);
					ShutdownDialogSettings(theDialog, dsp);
					EndDialog(theDialog, itemID);
					result = TRUE;
					break;				
				
				default:
					if (!IsWinDialogItemHitMessage(theDialog, itemID, notificationMessage))
						break;					// This is not a message that we need to handle.
					HandleItemHit(theDialog, itemID, dsp);
					break;
			}
			break;
	}
	return result;
}