Ejemplo n.º 1
0
// mir_free() the return value
char *CreateControlIdentifier(const char *pszDlgId, const char *pszModule, int ctrlId, HWND hwndCtl)
{
	int size;
	char *szId;
	TCHAR szDefCtlText[128];
	GetControlTitle(hwndCtl, szDefCtlText, _countof(szDefCtlText));
	size = lstrlenA(pszModule) + lstrlenA(pszDlgId) + _countof(szDefCtlText) + 22;
	szId = (char*)mir_alloc(size);
	mir_snprintf(szId, size, "[%s:%i@%s]\r\n%S%s", pszModule, ctrlId, pszDlgId, szDefCtlText, szDefCtlText[0] ? "=" : "");

	return szId;
}
Ejemplo n.º 2
0
static DialogRef DrawDialogTheMacOS8or9Way(void)
{
	short		i;
	ControlRef theControl;
	
	DialogRef theDialog = GetNewDialog(257, NULL, (WindowRef)-1L);
	if (theDialog == NULL) return(NULL);
	
	// Let's get a pulsing blue default button!
	GetDialogItemAsControl(theDialog, 1, &theControl);
	SetWindowDefaultButton(GetDialogWindow(theDialog), theControl);
	
	// Setting the check box
	GetDialogItemAsControl(theDialog, 2, &theControl);
	SetControl32BitValue(theControl, 1);
	
	// We need to autoembed our radio buttons in the radio group
	// so that they work automatically
	for (i = 4; i <= 8; i++)
	{
		GetDialogItemAsControl(theDialog, i, &theControl);
		AutoEmbedControl(theControl, GetDialogWindow(theDialog));
	}
	
	// we assign a key filter on our edit text box so that only digits can be entered
	ControlRef theTextControl;
	ControlKeyFilterUPP keyFilter = MyEditKeyFilter;
	GetDialogItemAsControl(theDialog, 9, &theTextControl);
	SetKeyboardFocus(GetDialogWindow(theDialog), theTextControl, kControlFocusNextPart);
	SetControlData(theTextControl, kControlEntireControl, kControlEditTextKeyFilterTag, sizeof(keyFilter), &keyFilter);
	
	// Setting the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work
	// We also associate the previous edit text box with the scroll bar so it gets updated
	GetDialogItemAsControl(theDialog, 14, &theControl);
	SetControlAction(theControl, ScrollBar32BitActionProc);
	SetControl32BitMaximum(theControl, 0x7fffffff);
	SetControlReference(theControl, (SInt32)theTextControl);
	
	// The static text control is created as a resource but we could only set its title and
	// not its content. We set the content now!
	GetDialogItemAsControl(theDialog, 15, &theControl);
	Str255 theTitle;
	GetControlTitle(theControl, theTitle);
	SetControlData(theControl, kControlEntireControl, kControlStaticTextTextTag, theTitle[0], &theTitle[1]);
	
	// We set up our User Pane Control with the draw, hit test, and track (actually action) procs
	GetDialogItemAsControl(theDialog, 13, &theControl);
	Rect bounds;
	GetControlBounds(theControl, &bounds);
	gUserH = (bounds.left + bounds.right) / 2;
	gUserV = (bounds.top + bounds.bottom) / 2;	
	ControlUserPaneDrawUPP userPaneDraw = MyUserPaneDrawProc;
	SetControlData(theControl, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(userPaneDraw), &userPaneDraw);
	ControlUserPaneHitTestUPP userPaneHitTest = MyUserPaneHitTestProc;
	SetControlData(theControl, kControlEntireControl, kControlUserPaneHitTestProcTag, sizeof(userPaneHitTest), &userPaneHitTest);
	SetControlAction(theControl, MoveSpotActionProc);
	
	ShowWindow(GetDialogWindow(theDialog));
	
	return(theDialog);
}