Jeg er har fundet nogle sidder om hvordan man kan indsætte en kalender i et program (
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/monthcal/monthcal.asp#mc_processing_MCN_GETDAYSTATE)PRoblemet er det, at jeg ikke kan fremhæve nogle bestemte dage. Gør jeg det bliver de fremhævet i samtlige måneder.
#include <windows>
#include <commctrl>
#include <map>
using namespace std;
HWND c_hwnd;
//////////////////////********** WndProc *************\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_NOTIFY: {
LPNMHDR hdr = (LPNMHDR) lParam;
switch (hdr->code) {
case MCN_GETDAYSTATE: {
NMDAYSTATE* pDayState = (NMDAYSTATE*) lParam;
MONTHDAYSTATE mds[3];
for(int i=0; i< pDayState->cDayState; ++i) {
mds[i] = (MONTHDAYSTATE) 0;
}
mds[1] |= 1<<15;
pDayState->prgDayState = mds;
}
break;
default:
break;
}
}
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
//////////////////////********** MAIN *************\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
RECT rc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = "Vækkeur_vindueklasse1";
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) {
MessageBox(NULL, "Vindueregistreringen har slået fejl.\\nProgrammet lukkes ned", "Fejl", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_DATE_CLASSES;
InitCommonControlsEx(&icex);
hwnd = CreateWindowEx (
WS_EX_CLIENTEDGE,
"Vækkeur_vindueklasse1",
"Indstillinger for opvækkning",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,
NULL, NULL, hInstance, NULL);
c_hwnd = CreateWindowEx (
0,
MONTHCAL_CLASS,
"",
WS_BORDER | WS_CHILD | WS_VISIBLE | MCS_DAYSTATE,
0, 0, 0, 0,
hwnd, NULL, hInstance, NULL);
if(hwnd==NULL || c_hwnd==NULL) {
MessageBox(NULL, "Vinduekreationen har slået fejl.\\nProgrammet lukkes.", "Fejl", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
MonthCal_GetMinReqRect(c_hwnd, &rc);
SetWindowPos(c_hwnd, NULL, 40, 35, 35 + rc.right, 40 + rc.bottom, SWP_NOZORDER);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0)>0) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
Som koden er nu markerer den den 16. i den nuværende måned, men når man skifter måned markerer den stadigvæk den 16.
Jeg har brugt flere dage på at få det til at fungere, så jeg ville blive meget glad hvis der var en der kunne hjælpe mig.