Jump to content

Transfering control between no. of listbox


Guest Ravi Ranjan

Recommended Posts

Guest Ravi Ranjan

Hi Every one,

I am creting a DialogBox having 12 listbox related with font ,size and colors, i need to transfer control from one listbox to another , for this i am using windowsubclassing, that is i have written 12 windowsubclass one for each control, but when i use arrow key to transfer the focus it jumps two control forward or two control backward, i traced the error it is going through inbetween subclassproc and focus goes to next-to-next control, and i am unable to remove highlight from previous control, ie at atime more than one control is having Highlighted background for selection. The code i am using is

LRESULT APIENTRY CDlgFont::ListRecSayFontSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndSendMsgcolor); 	 

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecSayFont,LB_SETSEL,FALSE,-1);	

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndRecSaySize);

  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecSayFont,LB_SETSEL,FALSE,-1);	

 	 break;

	}


    return CallWindowProc(m_OldProcListRecSayFont,hwnd, uMsg,wParam, lParam); 

}



LRESULT APIENTRY CALLBACK CDlgFont::ListRecSayFontSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListRecSayFontSubclassProc(hwnd,uMsg,wParam,lParam);

}




LRESULT APIENTRY CDlgFont::ListRecSaySizeSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndRecSayFont); 	 

    wParam=NULL;

    PeekMessage(&msg,NULL,0,1,PM_REMOVE);

    SendMessage(m_hwndRecSaySize,LB_SETSEL,FALSE,-1);	

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndRecSaycolor);

    wParam=NULL;

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecSaySize,LB_SETSEL,FALSE,-1);	

 	 break;

	}


    return CallWindowProc(m_OldProcListRecSaySize,hwnd, uMsg,wParam, lParam); 

}



LRESULT APIENTRY CALLBACK CDlgFont::ListRecSaySizeSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListRecSaySizeSubclassProc(hwnd,uMsg,wParam,lParam);

}




LRESULT APIENTRY CDlgFont::ListRecSaycolorSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndRecSaySize);	

    wParam=NULL;

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecSaycolor,LB_SETSEL,FALSE,-1);

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndRecMsgFont); 	 

    wParam=NULL;

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecSaycolor,LB_SETSEL,FALSE,-1);

 	 break;

	}


    return CallWindowProc(m_OldProcListRecSaycolor,hwnd, uMsg,wParam, lParam); 

}



LRESULT APIENTRY CALLBACK CDlgFont::ListRecSaycolorSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListRecSaycolorSubclassProc(hwnd,uMsg,wParam,lParam);

}




LRESULT APIENTRY CDlgFont::ListRecMsgFontSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndRecSaycolor);  

    //wParam=NULL;

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecMsgFont,LB_SETSEL,FALSE,-1);

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndRecMsgSize); 	 

    wParam=NULL;

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecMsgFont,LB_SETSEL,FALSE,-1);

 	 break;

	}


    return CallWindowProc(m_OldProcListRecMsgFont,hwnd, uMsg,wParam, lParam); 

}



LRESULT APIENTRY CALLBACK CDlgFont::ListRecMsgFontSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListRecMsgFontSubclassProc(hwnd,uMsg,wParam,lParam);

}



LRESULT APIENTRY CDlgFont::ListRecMsgSizeSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndRecMsgFont); 	 

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecMsgSize,LB_SETSEL,FALSE,-1);	

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndRecMsgcolor);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecMsgSize,LB_SETSEL,FALSE,-1);	

 	 break;

	}


    return CallWindowProc(m_OldProcListRecMsgSize,hwnd, uMsg,wParam, lParam); 

}



LRESULT APIENTRY CALLBACK CDlgFont::ListRecMsgSizeSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListRecMsgSizeSubclassProc(hwnd,uMsg,wParam,lParam);

}



LRESULT APIENTRY CDlgFont::ListRecMsgcolorSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT:

    SetFocus(m_hwndRecMsgSize); 	 

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecMsgcolor,LB_SETSEL,FALSE,-1);	

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndSendSayFont);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndRecMsgcolor,LB_SETSEL,FALSE,-1);	

 	 break;

	}


    return CallWindowProc(m_OldProcListRecMsgcolor,hwnd, uMsg,wParam, lParam); 

}



LRESULT APIENTRY CALLBACK CDlgFont::ListRecMsgcolorSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListRecMsgcolorSubclassProc(hwnd,uMsg,wParam,lParam);

}







LRESULT APIENTRY CDlgFont::ListSendSayFontSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndRecMsgcolor);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendSayFont,LB_SETSEL,FALSE,-1);	

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndSendSaySize);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendSayFont,LB_SETSEL,FALSE,-1);	

 	 break;

	}


    return CallWindowProc(m_OldProcListSendSayFont,hwnd, uMsg,wParam, lParam); 

}



LRESULT APIENTRY CALLBACK CDlgFont::ListSendSayFontSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListSendSayFontSubclassProc(hwnd,uMsg,wParam,lParam);

}




LRESULT APIENTRY CDlgFont::ListSendSaySizeSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndSendSayFont);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendSaySize,LB_SETSEL,FALSE,-1);	

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndSendSaycolor);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendSaySize,LB_SETSEL,FALSE,-1);	

 	 break;

	}


    return CallWindowProc(m_OldProcListSendSaySize,hwnd, uMsg,wParam, lParam); 

}


LRESULT APIENTRY CALLBACK CDlgFont::ListSendSaySizeSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListSendSaySizeSubclassProc(hwnd,uMsg,wParam,lParam);

}




LRESULT APIENTRY CDlgFont::ListSendSaycolorSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndSendSaySize);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendSaycolor,LB_SETSEL,FALSE,-1);

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndSendMsgFont);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendSaycolor,LB_SETSEL,FALSE,-1);

 	 break;

	}


    return CallWindowProc(m_OldProcListSendSaycolor,hwnd, uMsg,wParam, lParam); 

}


LRESULT APIENTRY CALLBACK CDlgFont::ListSendSaycolorSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListSendSaycolorSubclassProc(hwnd,uMsg,wParam,lParam);

}




LRESULT APIENTRY CDlgFont::ListSendMsgFontSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndSendSaycolor);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendMsgFont,LB_SETSEL,FALSE,-1);	

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndSendMsgSize);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendMsgFont,LB_SETSEL,FALSE,-1);	

 	 break;

	}


    return CallWindowProc(m_OldProcListRecMsgcolor,hwnd, uMsg,wParam, lParam); 

}


LRESULT APIENTRY CALLBACK CDlgFont::ListSendMsgFontSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListSendMsgFontSubclassProc(hwnd,uMsg,wParam,lParam);

}



LRESULT APIENTRY CDlgFont::ListSendMsgSizeSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndSendMsgFont);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendMsgSize,LB_SETSEL,FALSE,-1);	

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndSendMsgcolor);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendMsgSize,LB_SETSEL,FALSE,-1);	

 	 break;

	}


    return CallWindowProc(m_OldProcListSendMsgSize,hwnd, uMsg,wParam, lParam); 

}



LRESULT APIENTRY CALLBACK CDlgFont::ListSendMsgSizeSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListSendMsgSizeSubclassProc(hwnd,uMsg,wParam,lParam);

}





LRESULT APIENTRY CDlgFont::ListSendMsgcolorSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{ 

	switch(wParam)

	{	MSG msg;

  case VK_LEFT    :

    SetFocus(m_hwndSendMsgSize);  

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendMsgcolor,LB_SETSEL,FALSE,-1);	

 	 break;

  case VK_RIGHT :

    SetFocus(m_hwndRecSayFont); 	 

    PeekMessage(&msg,NULL,0,0,PM_REMOVE);

    SendMessage(m_hwndSendMsgcolor,LB_SETSEL,FALSE,-1);	

 	 break;

	}


    return CallWindowProc(m_OldProcListRecMsgcolor,hwnd, uMsg,wParam, lParam); 

}




LRESULT APIENTRY CALLBACK CDlgFont::ListSendMsgcolorSubclassProcStatic(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) 

{

 return m_this->ListSendMsgcolorSubclassProc(hwnd,uMsg,wParam,lParam);

}

I am surprised why the focus jumps two control forward or two control backward, and why the highlight doesnot goes off.

I have allready tried to create window from API using CreateWindow() but still it is not working

Can any one help me . THanks in Advance.

Ravi Ranjan :) :cry:

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.