Example #1
0
LOCAL BOOL ListBox_OnCreate(HWND hWindow, CREATESTRUCT FAR* lpCreateStruct)
/***********************************************************************/
{
LPLISTBOXDATA lpData;
LONG lResult;

lpData = (LPLISTBOXDATA)Alloc(sizeof(LISTBOXDATA));
if (!lpData)
	return(FALSE);
clr((LPTR)lpData, sizeof(LISTBOXDATA));
lpData->fEnableMove = TRUE;
SetWindowLong(hWindow, ListBox_WindowExtra, (long)lpData);
lResult = FORWARD_WM_CREATE(hWindow, lpCreateStruct, ListBox_CallWindowProc);
return(lResult >= 0);
}
Example #2
0
BOOL FAR PASCAL _EXPORT openMDITab(HWND hwnd, LPTabData lpTabData)
{
#if defined(_WIN32)
    HMODULE hInstance=InstanceFromWindow(hwnd);
    LPWORD p, lpCreateParams;
#else
    HINSTANCE hInstance=InstanceFromWindow(hwnd);
    LPBYTE p, lpCreateParams;
#endif
    LPBYTE lpszClass, lpszText = NULL;
    HWND hwndPrevChild=GetDlgItem(hwnd, lpTabData->nFrame);
    HFONT hFont;
    int nIndex=TabCtrl_GetCurSel(lpTabData->hwndTab);
    LPDLGTEMPLATE lpDlgTemplate;
    LPDLGITEMTEMPLATE lpDlgItemTemplate;
    LPFONTINFO lpFontInfo;
    HWND hwndChild;
    int nNumControls;
    RECT rc;

    if (nIndex<0)
		return(FALSE);

	ShowWindow(GetDlgItem(hwnd, 990), SW_HIDE);

    lpTabData->nIndex=nIndex;
    lpDlgTemplate=lpTabData->lpTabList[nIndex].lpDlgTemplate;

    hFont=GetWindowFont(hwndPrevChild);//(hwnd);

    //  Ignore everything in Dialog Template except for the number
    //  of controls.
    nNumControls=lpDlgTemplate->cdit;

#if defined(_WIN32)
    p=(LPWORD)(&lpDlgTemplate->cy+1); 	//  Start of Menu name
#if defined(_TABDEBUG)
    checkResource(hwnd, p, "Start of menu name");
#endif

    if (*p==0xffff)			//  Skip the menu name string
	p+=2;
    else
	while(*p++);

#if defined(_TABDEBUG)
    checkResource(hwnd, p, "Start of class name");
#endif

    if (*p==0xffff)			//  Skip the Class name string
		p+=2;
    else
		while(*p++);

#if defined(_TABDEBUG)
    checkResource(hwnd, p, "Start of caption");
#endif
#else
    p=(LPBYTE)(&lpDlgTemplate->cy+1); 	//  Start of Menu name
    while (*p++);           		//  Skip the menu name string
    while (*p++);           		//  Skip the Class name string
#endif
    while (*p++);           		//  Skip the Caption string
    lpFontInfo=(LPFONTINFO)p; 		//  Start of FONTINFO (if exists)

    //  Find address of first DLGITEMTEMPLATE structure
    if (lpDlgTemplate->style&DS_SETFONT) 
	{
#if defined(_WIN32)
		p=(LPWORD)(&lpFontInfo->PointSize+1);
#if defined(_TABDEBUG)
		checkResource(hwnd, p, "Start of font name");
#endif
#else
		p=(LPBYTE)(&lpFontInfo->PointSize+1);
#endif
		while (*p++);  			//  Skip the Type face name string
		lpDlgItemTemplate=(LPDLGITEMTEMPLATE)p;
	} 
	else
		lpDlgItemTemplate=(LPDLGITEMTEMPLATE)lpFontInfo;

    //  Create all of the child controls
    while (nNumControls--) 
	{
#if defined(_WIN32)
		LPWORD lpwzClass=(LPWORD)(&lpDlgItemTemplate->id+1);
		BYTE szClassBuffer[64];
		LPWORD lpwzText;
		BYTE szTextBuffer[128];
		int nCount;

		lpDlgItemTemplate=(LPDLGITEMTEMPLATE)normalise(lpDlgItemTemplate, lpDlgTemplate, 1);
		lpwzClass=(LPWORD)(&lpDlgItemTemplate->id+1);

		if (*lpwzClass==0xffff) 
		{
			nCount=2;
			lpwzText=lpwzClass+2;
			lpszClass=(LPBYTE)szPredefinedClassNames[*(lpwzClass+1)-PREDEFINEDCNTRLBIT];
		} 
		else 
		{
			lpszClass=szClassBuffer;
			nCount=strcpy16to8(szClassBuffer, lpwzClass)+1;
			lpwzText=lpwzClass+nCount;
		}

#if defined(_TABDEBUG)
		checkResource(hwnd, (LPINT)lpDlgItemTemplate, "Start of child control %d of %d, class \"%s\"",
		      lpDlgTemplate->cdit-nNumControls, lpDlgTemplate->cdit, lpszClass);
#endif

		if (*lpwzText==0xffff) 
		{
			nCount+=2;
			lpszText=(LPBYTE)MAKELONG(*(lpszText+1), 0);
		} 
		else 
		{
			lpszText=szTextBuffer;
			nCount+=strcpy16to8(szTextBuffer, lpwzText)+1;
		}

		lpCreateParams=normalise(lpwzClass+nCount-1, lpDlgTemplate, 2);
#else
		lpszClass=(LPBYTE)(&lpDlgItemTemplate->style+1);

		if (*lpszClass&PREDEFINEDCNTRLBIT) 
		{
			lpszText=lpszClass+1;
			lpszClass=(LPBYTE)szPredefinedClassNames[(WORD)(*lpszClass)-PREDEFINEDCNTRLBIT];
		} 
		else
			for (lpszText=lpszClass; *lpszText++;);

	//  Find address of number-of-bytes-in-additional-data
		for (lpCreateParams=lpszText; *lpCreateParams++;);
#endif

	//  Do not create any windows with an ID of uIDChangeableArea
	//  This control was used for reference when the template was
	//  created and should not be created.
		if (lpDlgItemTemplate->id!=lpTabData->nFrame) 
		{
			RECT			rcTab;
			DWORD			tInt, cxFact, cyFact;
            
			GetClientRect(GetDlgItem(hwnd, 990), &rcTab);

			cxFact = ((rcTab.right-rcTab.left)*100)/50;
			cyFact = ((rcTab.bottom-rcTab.top)*100)/14;

			tInt	  = (DWORD)(lpDlgItemTemplate->x)*(DWORD)cxFact / 100L;
			rc.left   = (short)tInt;
			tInt	  = (DWORD)(lpDlgItemTemplate->y)*(DWORD)cyFact / 100L;
			rc.top    = (short)tInt;
			tInt	  = (DWORD)(lpDlgItemTemplate->x+lpDlgItemTemplate->cx)*(DWORD)cxFact / 100L;
			rc.right  = (short)tInt;
			tInt	  = (DWORD)(lpDlgItemTemplate->y+lpDlgItemTemplate->cy)*(DWORD)cyFact / 100L;
			rc.bottom = (short)tInt;

			hwndChild=CreateWindowEx(WS_EX_NOPARENTNOTIFY,
				     (LPCSTR)lpszClass, (LPCSTR)lpszText,
				     lpDlgItemTemplate->style,
				     rc.left,
					 rc.top,
					 rc.right-rc.left,
					 rc.bottom-rc.top,
				     hwnd, (HMENU)lpDlgItemTemplate->id, hInstance,
				     lpCreateParams);

			if (!hwndChild) 
			{
		//  The child couldn't be created
				alert(hwnd, "Failed to create control %d (class %s)",
						lpDlgTemplate->cdit-nNumControls+1, lpszClass);

				return(FALSE);
			}

	    //  Tell the new control to use the same font as dialog box
			SetWindowFont(hwndChild, hFont, FALSE);

	    // Fix the Z-Order of the controls
			SetWindowPos(hwndChild, hwndPrevChild, 0, 0, 0, 0,
				 SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
			
			RePositionControl(hwnd, lpDlgItemTemplate->id);

			hwndPrevChild=hwndChild;
		}

	// Point to the next DlgItemTemplate
		lpDlgItemTemplate=(LPDLGITEMTEMPLATE)(lpCreateParams+1+ *lpCreateParams);
    }
	
    FORWARD_WM_CREATE(hwnd, 0, lpTabData->lpTabList[nIndex].fpDlgProc);
    return(TRUE);
}