How can i make my program call a function in the moment when an item is chosen from a combo box list?

I just made a combo box that is contained inside a Rebar control. The combo box is designed to contain a list of a bunch of Fonts (times new roman, arial, etc)


I am trying to make the items in the combo box execute an application defined function when they are chosen, but i am having some trouble doing that

I added one item on the list (Times New Roman) and i also have an application defined function that changes the the text to times new roman. So how exactly can i execute my application defined function when the item (Times New Roman) is chosen from the list in the combo box?

here is the code that adds a combo box to a rebar control (combo box has already been created)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void CreateComboBoxBand()
{
	REBARBANDINFO combobox;													
	RECT coordinates;														
	GetWindowRect(ComboBox,&coordinates);									

        combobox.cbSize = REBARBANDINFO_V3_SIZE;								
	combobox.fMask = RBBIM_STYLE | RBBIM_CHILD |							
					 RBBIM_CHILDSIZE | RBBIM_SIZE |
					 RBBIM_TEXT;
	combobox.fStyle = RBBS_GRIPPERALWAYS | RBBS_CHILDEDGE;					
	combobox.cyMinChild = coordinates.bottom - coordinates.top;				
	combobox.cx = 100;															
	combobox.lpText = L"Font";												 										
	combobox.hwndChild = ComboBox;											

	SendMessage(ComboBox, CB_ADDSTRING, (WPARAM)1, (LPARAM) L"Times New Roman"); /* Adding a new item on the list */
	SendMessage(RebarControl, RB_INSERTBAND, (WPARAM)0, (LPARAM)&combobox);
}



and here is my application defined function that changes the text in the rich edit control window to Time New Roman

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


void ChangeFontToTimesNewRoman(HWND richedit)
{
	CHARFORMAT romanfont;

	romanfont.cbSize = sizeof(CHARFORMAT);								
	romanfont.dwMask = CFM_FACE | CFM_CHARSET | CFM_BOLD | CFM_ITALIC;	      
        romanfont.bCharSet = ANSI_CHARSET;									
	lstrcpy(romanfont.szFaceName, L"Times New Roman");					

	SendMessage(richedit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&romanfont);
}




Last edited on
Never mind. I figured it out.
Topic archived. No new replies allowed.