/*I wanted to create Caret Over my "DiaryCom" window which is a child window but it dont work, I need some help. only two function are given where caret creation took place*/ Code: BOOL RegisterNCreateDiary() { WNDCLASS wc; RECT rect; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = NULL; //I wanted to use Mainwindow Background wc.hCursor = LoadCursor(NULL,IDC_IBEAM); wc.hIcon=NULL; wc.hInstance=g_hinst; wc.lpfnWndProc=DiaryWndProc; wc.lpszClassName=TEXT("DiaryCom"); wc.lpszMenuName=NULL; wc.style=0; if(!RegisterClass(&wc)) return FALSE; GetClientRect(ghwnd,&rect); rect.bottom -=50; rect.left +=50 ; rect.right-=50; rect.top+=100; //Creating "DiaryCom" DiaryHwnd = CreateWindow(TEXT("DiaryCom"), NULL, WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, ghwnd, NULL, g_hinst, NULL); if(!DiaryHwnd) return FALSE; UpdateWindow(DiaryHwnd); return TRUE; } LRESULT __stdcall DiaryWndProc(HWND hWnd,UINT msg,WPARAM wParam, LPARAM lParam) { HWND hwnd; switch(msg) { case WM_SETFOCUS: //it actually never work CreateCaret(hWnd,NULL,20,2); SetCaretPos(100,100); ShowCaret(hWnd); return 0; case WM_KILLFOCUS: //its always work, but i dont want it to work HideCaret(hWnd); DestroyCaret(); return 0; case WM_PAINT: return 0; } return DefWindowProc(hWnd,msg,wParam,lParam); }
Please use a code block. It's really easy, just add [ code ] before the code and [ /code ] after (without the spaces). And it makes code considerably easier to read.