Combo Box problem in MFC dialog application :
----------------------------------------------
1.I added the combo box to the dialog and added the string to the combo box using the following code...
CComboBox* combo = (CComboBox*) GetDlgItem( IDC_COMBO1 );
combo->AddString( "one" );
combo->AddString( "two" );
combo->AddString( "three" );
If I checked the count, it returns 3 But it didnt display the text "one,two,three" on screen.
Solution:
---------
Make sure you size the combo box in the resource editor so it is big enough. Click
on the little arrow and then drag the bottom handle square down. If you are doing it in
code, make sure the rect is big enough to fit the drop-down.
I opened the .rc file in a resource editor and modified the
combo box values , Now it displays the data .The problem is combo box height is not big to display
the combo box items in a drop down or drop List
Showing posts with label MFC problems. Show all posts
Showing posts with label MFC problems. Show all posts
Monday, November 26, 2007
Tuesday, May 22, 2007
Radio Buttons selection Problem
Tips Only for VC++ Developers
-----------------------------------------------
read this article with patience u may wonder the things about it...
I explained each and every steps ... So Dont mistake me....( u r all genius but I am so stupid to
rememeber the things...)
Follow the steps :
-----------------------
1.Open the Visual Studio 6.0
2.Select the "MFC AppWizard Exe" option
3. Give the project name
4.Select the "Dialog based application" and click the "Finish" button.
5.Next Click on "Resources" Tab in the Source code Browse window
6.Within Resources, click on Dialog and select the program's dialog
Do the following steps in Sequence :
7. Place the "Group Box" in the dialog we can call it as GroupBox1
8.Place two option buttons(Radio1,Radio2) within this GroupBox1
9. Place another "Group Box" in the dialog we can call it as GroupBox2
10.Place two option buttons(Radio3,Radio4) within this GroupBox2
11. run the application
12.Select the radio1 button in GroupBox1.
13.Next Select radio3 button in GroupBox2.Now the radio3 button is selected but the previous selection
radio1 button is deselected...
Am I right ?
Actually in a programming scenario,
the selection of radio button in one GroupBox must not affect the selection of radio button in another groupBox.
Here it is not like that...
So we have to do some thing different...
How can we make the selection of radio button in one GroupBox must not affect the selection of radio button in another groupBox ?
Solution :
Right click the Radio1 button's properties and select the "Group" check box .
Right click the radio3 button's properties and select the "Group" check box.
At conclusion :
make sure all the controls are placed in consecutive tab order.
(select the menu Layout-->Tab Order (Ctrl+D) )
For the 1st radio button, make sure the "Group" flag is set true (WS_GROUP, but you can do it in the resource editor.)
(select the "Group" check box of the first radio button).
Make sure the rest of the radio buttons have the "Group" flag set false.(unchecked status of "Group" check box of the first radio button).
The "Group" flag tells Windows that this control is the 1st control in a group.
( we may check it by opening the .rc file in a notepad )
Note :- But if u are selecting the "Group" check box of all the radio properties .
See the result.
PostScript :
I faced this problem during developement and finally got a solution for this problem... thanks for ur patience.Sorry for my bad tanglish..
-----------------------------------------------
read this article with patience u may wonder the things about it...
I explained each and every steps ... So Dont mistake me....( u r all genius but I am so stupid to
rememeber the things...)
Follow the steps :
-----------------------
1.Open the Visual Studio 6.0
2.Select the "MFC AppWizard Exe" option
3. Give the project name
4.Select the "Dialog based application" and click the "Finish" button.
5.Next Click on "Resources" Tab in the Source code Browse window
6.Within Resources, click on Dialog and select the program's dialog
Do the following steps in Sequence :
7. Place the "Group Box" in the dialog we can call it as GroupBox1
8.Place two option buttons(Radio1,Radio2) within this GroupBox1
9. Place another "Group Box" in the dialog we can call it as GroupBox2
10.Place two option buttons(Radio3,Radio4) within this GroupBox2
11. run the application
12.Select the radio1 button in GroupBox1.
13.Next Select radio3 button in GroupBox2.Now the radio3 button is selected but the previous selection
radio1 button is deselected...
Am I right ?
Actually in a programming scenario,
the selection of radio button in one GroupBox must not affect the selection of radio button in another groupBox.
Here it is not like that...
So we have to do some thing different...
How can we make the selection of radio button in one GroupBox must not affect the selection of radio button in another groupBox ?
Solution :
Right click the Radio1 button's properties and select the "Group" check box .
Right click the radio3 button's properties and select the "Group" check box.
At conclusion :
make sure all the controls are placed in consecutive tab order.
(select the menu Layout-->Tab Order (Ctrl+D) )
For the 1st radio button, make sure the "Group" flag is set true (WS_GROUP, but you can do it in the resource editor.)
(select the "Group" check box of the first radio button).
Make sure the rest of the radio buttons have the "Group" flag set false.(unchecked status of "Group" check box of the first radio button).
The "Group" flag tells Windows that this control is the 1st control in a group.
( we may check it by opening the .rc file in a notepad )
Note :- But if u are selecting the "Group" check box of all the radio properties .
See the result.
PostScript :
I faced this problem during developement and finally got a solution for this problem... thanks for ur patience.Sorry for my bad tanglish..
Tuesday, March 27, 2007
How to find the width and height of the text with specified font ?
How to find the width and height of the text with specified font :
LOGFONT logFont... which holds information about the selected font...
HFONT hFont = CreateFontIndirect(&logfont);
SelectObject(graphics->GetHdc(),(HGDIOBJ)hFont);
GetTextExtentPoint32 () ... returns the width and height of the text
we can get width here...
we may get Height From the following :
TextMetrics tm;
GetTextMetrics(&tm);
tm.Height - Height of the text....
The GetTextExtentPoint32 function computes the width and height of the specified string of text. the GetTextExtentPoint32 function initializes the members of a SIZE structure with the length and height of the specified string. The GetTextMetrics function retrieves the overhang for the current font. Because the overhang is zero if the font is a TrueType font, the overhang value does not change the string placement. For raster fonts, however, it is important to use the overhang value.
LOGFONT logFont... which holds information about the selected font...
HFONT hFont = CreateFontIndirect(&logfont);
SelectObject(graphics->GetHdc(),(HGDIOBJ)hFont);
GetTextExtentPoint32 () ... returns the width and height of the text
we can get width here...
we may get Height From the following :
TextMetrics tm;
GetTextMetrics(&tm);
tm.Height - Height of the text....
The GetTextExtentPoint32 function computes the width and height of the specified string of text. the GetTextExtentPoint32 function initializes the members of a SIZE structure with the length and height of the specified string. The GetTextMetrics function retrieves the overhang for the current font. Because the overhang is zero if the font is a TrueType font, the overhang value does not change the string placement. For raster fonts, however, it is important to use the overhang value.
Subscribe to:
Posts (Atom)