/**************/ /* aanesta.c */ /***************************************************************************** PROGRAM: aanesta.c Windows: Win 3.1 & WIN32 PURPOSE: Malli "äänestyskoneesta" Editor: Vesa Lappalainen 23.10.1994 PROJECT: aanesta.c, aanesta.rc, ALI\def.def, ALI\bitmap.c, ALI\tausta.c, ALI\tabhand.c, ALI\mdialog.c, ALI\mjonot.c *****************************************************************************/ #include #include #include "tabhand.h" #include "tausta.h" #include "mjonot.h" #include "aanesta.rh" /****************************************************************************/ /* Jotta voidaan vastata viestiin WM_CTLCOLOR pitää olla ikkunafunktio! */ /* Täytyy siis tehdä luokallinen dialogi, johon tehdään sekä ikkunafunktio */ /* että dialogin funktio */ TDIALOGPROC(MsgTbl,VoteDlgProc) TCDIALOGPROC(MsgTbl,VoteWndProc) mClassDlgMAINWC("Voteclass","ikoni",NULL,"Aanesta",VoteWndProc,VoteDlgProc,NULL) /****************************************************************************/ static int valittu = ID_EOS - ID_KYLLA; static EVENT WM_command_VALITSE(tMSGParam *msg) /* #man# */ { valittu = msg->id - ID_KYLLA; return 0; } static EVENT WM_command_ID_AANESTA(tMSGParam *msg) { int n; char st[100],s[20]; n = GetDlgItemInt(msg->hWnd,ID_NKYLLA+valittu,NULL,TRUE); GetDlgItemText(msg->hWnd,ID_KYLLA+valittu,s,sizeof(s)); poista_merkit(s,"&"); wsprintf(st,"Äänestät siis %s",(LPSTR)s); if ( IsDlgButtonChecked(msg->hWnd,ID_VARMISTUS) == 0 || MessageBox(msg->hWnd,st,"Äänestys",MB_ICONEXCLAMATION | MB_OKCANCEL) == IDOK ) SetDlgItemInt(msg->hWnd,ID_NKYLLA+valittu,n+1,TRUE); return 0; } static HBRUSH hBrGreen = NULL; static EVENT WM_initdialog(tMSGParam *msg) { CheckDlgButton(msg->hWnd,ID_KYLLA+valittu,TRUE); AlustaTaustaHWND(NULL,msg->hWnd,"kuva",2); hBrGreen = CreateSolidBrush(RGB(0,255,0)); return 0; } static EVENT WM_ctlcolor(tMSGParam *msg) { (void)msg; // SetBkMode((HDC)msg->wParam,TRANSPARENT); // Miksi tämä ei ole hyvä?? SetBkColor((HDC)msg->wParam,RGB(0,255,0)); if ( HIWORD(msg->lParam) == CTLCOLOR_BTN ) return (LONG)hBrGreen; return (LONG)GetStockObject(HOLLOW_BRUSH); } static EVENT WM_close(tMSGParam *msg) { (void)msg; DeleteObject(hBrGreen); PostQuitMessage(0); return 0; } /****************************************************************************/ /* Viestien käsittelytaulukko */ /****************************************************************************/ tMSGEntry MsgTbl[] = { LOOK_TABLE(TaustaMsgTbl), { WM_COMMAND , TRANGE , DoC , WM_command_VALITSE , 0, 0, ID_KYLLA,ID_EOS }, { WM_COMMAND , ID_AANESTA , DoC , WM_command_ID_AANESTA }, /*a*/ { WM_INITDIALOG , DoC , DoC , WM_initdialog }, /*a*/ { WM_CTLCOLOR , DoC , DoC , WM_ctlcolor }, /*a*/ { WM_CLOSE , DoC , DoC , WM_close }, /*a*/ { 0 } }; /****************************************************************************/