1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Caret Prob

Discussion in 'Win32' started by johny10151981, Oct 14, 2008.

  1. johny10151981

    johny10151981 New Member

    Joined:
    Jul 7, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    /*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);
    }
     
  2. imported_xpi0t0s

    imported_xpi0t0s New Member

    Joined:
    Jul 18, 2008
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  3. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    I have added the code blocks for you as of now.
     

Share This Page