?? alckey.c
字號:
{
SKBINFO skb;
if (heditFocusWnd)
SetFocus(heditFocusWnd);
ShowKeyboard(hWnd,SKB_QUERY,NULL, &skb);
if (!skb.fVisible)
{
ShowKeyboard(hWnd,SKB_SHOW,NULL,&skb);
}
else
{
ShowKeyboard(hWnd, SKB_HIDE,NULL,&skb);
}
}
break;
}
break;
case WM_MEASUREITEM:
{
int nIDCtl;
LPMEASUREITEMSTRUCT lpmisCtl;
nIDCtl = (int) wParam; /* control identifier */
lpmisCtl = (MEASUREITEMSTRUCT FAR*) lParam; /* address of structure */
}
break;
case WM_DRAWITEM:
{
int nIDCtl;
LPDRAWITEMSTRUCT lpdis;
HDC hMemDC;
HBITMAP hOldBitmap;
BITMAP bm;
nIDCtl = (int) wParam; /* control identifier */
// lpdis = (const DRAWITEMSTRUCT FAR*) lParam; /* structure */
lpdis = (LPDRAWITEMSTRUCT) lParam;
GetObject(hKBUp,sizeof(BITMAP),&bm);
//check for state of button .. the only ownerdraw control in this app.
switch (lpdis->itemAction) {
case ODA_DRAWENTIRE:
/* Redraw the entire control or menu. */
case ODA_SELECT:
/* Redraw to reflect current selection state. */
hMemDC = CreateCompatibleDC(lpdis->hDC);
if ((lpdis->itemState && ODS_SELECTED) != 0) //bit is set if not equal to zero
hOldBitmap = SelectObject(hMemDC,hKBDown);
else
hOldBitmap = SelectObject(hMemDC, hKBUp);
StretchBlt(lpdis->hDC,0,0,40,40,hMemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
SelectObject(hMemDC, hOldBitmap);
DeleteDC(hMemDC);
return TRUE;
case ODA_FOCUS:
/* Redraw to reflect current focus state. */
hMemDC = CreateCompatibleDC(lpdis->hDC);
if ((lpdis->itemState && ODS_FOCUS) != 0) //bit is set if not equal to zero
hOldBitmap = SelectObject(hMemDC,hKBDown);
else
hOldBitmap = SelectObject(hMemDC, hKBUp);
StretchBlt(lpdis->hDC,0,0,40,40,hMemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
SelectObject(hMemDC, hOldBitmap);
DeleteDC(hMemDC);
return TRUE;
} //end of switch
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return (DefWindowProc(hWnd, message, wParam, lParam));
}
return (FALSE);
}
/****************************************************************************
FUNCTION: About(HWND, unsigned, WORD, LONG)
PURPOSE: Processes messages for "About" dialog box
MESSAGES:
WM_INITDIALOG - initialize dialog box
WM_COMMAND - Input received
****************************************************************************/
BOOL _far _pascal About(HWND hDlg, unsigned message, WORD wParam, LONG lParam)
{
switch (message)
{
case WM_INITDIALOG:
return (TRUE);
case WM_COMMAND:
if (wParam == IDOK || wParam == IDCANCEL)
{
EndDialog(hDlg, TRUE);
return (TRUE);
}
break;
}
return (FALSE);
}
/****************************************************************************
FUNCTION: AlcDlgProc(HWND, unsigned, WORD, LONG)
PURPOSE: Processes messages for "Alc Dialog" dialog box
MESSAGES:
WM_INITDIALOG - initialize dialog box
WM_COMMAND - Input received
****************************************************************************/
BOOL _far _pascal AlcDlgProc(HWND hDlg, unsigned message, WORD wParam, LONG lParam)
{
DWORD dwIndex;
RC rc;
char szAlcTmp[30];
LPSTR lpAlcBeg, lpAlcEnd, lpAlc, lpAlcOrg;
int j;
LONG y;
DWORD dwx;
HRSRC hAlcValues; //alc string resource handle in rc file
HGLOBAL hAlcGlobal; //global memory handle of alc resource string
BOOL fContinue = TRUE;
switch (message)
{
case WM_INITDIALOG:
{
//load values into listbox for ALC use
if (hAlcValues = FindResource(hInst, (LPCSTR)ID_ALCSTRINGS, (LPCSTR)RT_RCDATA))
if (hAlcGlobal = LoadResource(hInst, hAlcValues))
lpAlc = (LPSTR)LockResource(hAlcGlobal);
lpAlcOrg = lpAlc;
lpAlcBeg = lpAlc;
lpAlcEnd = lpAlc;
while (fContinue)
{
lpAlc++;
//must find a way to check for eof right off..
if (!(*lpAlc != 0))
break;
if (*lpAlcEnd != '{')
{
lpAlcEnd++;
}
else
{
//initialize tmp array back to null
for (j=0; j<30; j++)
szAlcTmp[j] = 0;
_fmemcpy((void _far *)szAlcTmp,lpAlcBeg,(int)(lpAlcEnd-lpAlcBeg));
//is this the terminating string?
if ((szAlcTmp[0] == 'E')&&(szAlcTmp[1] == 'O')&&(szAlcTmp[2] == 'S'))
{
fContinue = FALSE;
break; //out of the loop
}
dwIndex = SendDlgItemMessage(hDlg, ID_ALCLISTBOX, LB_ADDSTRING, 0, (LPARAM)((LPSTR)szAlcTmp));
//pick up alc hex value
for (j=0; j<30; j++)
szAlcTmp[j] = 0;
_fmemcpy((void _far *)szAlcTmp,lpAlcEnd+1,10); //format has 10 numerics in it
dwx = atol(szAlcTmp);
//associate the value with that listbox item
SendDlgItemMessage(hDlg,ID_ALCLISTBOX,LB_SETITEMDATA,(WORD)dwIndex,(LPARAM)dwx);
y = SendDlgItemMessage(hDlg,ID_ALCLISTBOX,LB_GETITEMDATA,(WORD)dwIndex,0L);
//go to start of next valid alc code
while (*lpAlcEnd != '!')
lpAlcEnd++;
lpAlcBeg = ++lpAlcEnd;
//increment lpAlc to new position
lpAlc = lpAlcEnd;
}
}
return (TRUE);
}
case WM_COMMAND:
switch (wParam)
{
case ID_SELECT:
{
LPSTR lp;
HWND hwndMyEdit;
char szBuffer[32] ;
int count, retct;
int szCount[32];
LONG alcvalue=0;
int i;
hwndMyEdit = GetDlgItem(hDlg, ID_ALCEDIT);
SendMessage(hwndMyEdit, WM_GETTEXT, sizeof(szBuffer),
(LPARAM) ((LPSTR) szBuffer));
lp = szBuffer;
//get rc for hedit control and reset to new values for alc
if (SendMessage(hWndHedit, WM_HEDITCTL, HE_GETRC, (LONG)((LPRC)&rc)))
{
rc.alc = alcvalue = ALC_USEBITMAP;
//initialize szCount to nothing
count = (int)SendDlgItemMessage(hDlg,ID_ALCLISTBOX,LB_GETSELCOUNT,0,0L);
for (i=0; i<count; i++)
szCount[i] = 0;
retct = (int)SendDlgItemMessage(hDlg,ID_ALCLISTBOX,LB_GETSELITEMS,(WPARAM)count,(LPARAM)(int FAR*)szCount);
for (i=0; i <count; i++)
{
alcvalue = SendDlgItemMessage(hDlg,ID_ALCLISTBOX,LB_GETITEMDATA,(WORD)szCount[i],0L);
rc.alc = rc.alc|alcvalue;
}
if (rc.alc&ALC_USEBITMAP)
SetAlcBits(&rc, lp);
SendMessage(hWndHedit, WM_HEDITCTL, HE_SETRC, (LONG)((LPRC)&rc));
} //end if
}
break;
case ID_DONE:
{
EndDialog(hDlg, TRUE);
return (TRUE);
}
break;
default:
break;
}//end switch
}
return (FALSE);
}
/*----------------------------------------------------------
Purpose: Set the bits for ALC_USEBITMAP field
Returns: --
*/
VOID SetAlcBits(
LPRC lprc,
LPSTR lp)
{
int ib;
//wipe out all the old values (initialization to '0')
for (ib=0; ib<32; ib++)
lprc->rgbfAlc[ib] = 0; //this is faster than using the macros
for ( ; *lp != 0; lp++)
{
SetAlcBitAnsi (lprc, *lp); //use the ALC macro here
}
}
/* END OF FILE */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -