-
[RESOLVED] How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Can any one tell/provide code snippet for making the CEdit(EDITTEXT box) and CComboBox of
flat style?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Did you try to set the Border property to False?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Can you please tell how to do it..
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
Can you please tell how to do it..
Right click on the edit control and select properties
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Way of doing it with code lines?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
Way of doing it with code lines?
Have a look at the CEdit::Create
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
I used NOT WS_EX_CLIENTEDGE in .rc to remove the sunked edge from CEdit(EDITTEXT) but it is still showing Sunked/raised edge from left and topside?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
I used NOT WS_EX_CLIENTEDGE in .rc to remove the sunked edge from CEdit(EDITTEXT) but it is still showing Sunked/raised edge from left and topside?
You should remove the WS_BORDER style: https://docs.microsoft.com/en-us/win.../window-styles
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
When i used NOT WS_BORDER in .rc than it removed the entire boundaries from CEdit means box with no surroundings ..Any idea why, NOT WS_EX_CLIENTEDGE not working? My basic is issue is to remove that raised effect from left and top edge of CEdit
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
When i used NOT WS_BORDER in .rc than it removed the entire boundaries from CEdit means box with no surroundings ..Any idea why, NOT WS_EX_CLIENTEDGE not working? My basic is issue is to remove that raised effect from left and top edge of CEdit
Sorry, I couldn't get you.
Could you attach a picture with what you have and another one with what you want?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
When i used NOT WS_BORDER in .rc than it removed the entire boundaries from CEdit means box with no surroundings ..Any idea why, NOT WS_EX_CLIENTEDGE not working? My basic is issue is to remove that raised effect from left and top edge of CEdit
It's an extended style so you'll need to use CreateEx
-
1 Attachment(s)
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Attachment 35837
I have above one and i want below one.
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
One more suggestion: use Spy++ to obtain the styles of the control you are going to impement
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Means with no flags or functions i can achive second edit box. I have to use CreatEx for that?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Is there some reason you're not using the resource editor?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Hi GCDEF i used the resource editor and set the border to false which resulted in loss of boundaries of box , i also set client edge as false from there but no effect. As told i want the second box in the image i pasted above
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
Hi GCDEF i used the resource editor and set the border to false which resulted in loss of boundaries of box , i also set client edge as false from there but no effect. As told i want the second box in the image i pasted above
Again. use Spy++ as I wrote you in the post#13
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
I used the below code for creating CEdit dynamically, code compiled but editbox is not visible on screen.
Code:
CEdit *tedit = new CEdit;
tedit->CreateEx(WS_EX_CLIENTEDGE , L"Edit", L" ", ES_AUTHOSCROLL | WS_BORDER | WS_VISIBLE | WS_CHILD , CRect(15,150,30,20),this, IDC_EDIT);
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Is the CRect(15,150,30,20) within the parent?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
I used the below code for creating CEdit dynamically, code compiled but editbox is not visible on screen.
Code:
CEdit *tedit = new CEdit;
tedit->CreateEx(WS_EX_CLIENTEDGE , L"Edit", L" ", ES_AUTHOSCROLL | WS_BORDER | WS_VISIBLE | WS_CHILD , CRect(15,150,30,20),this, IDC_EDIT);
Look at the order of parameters for the CRect constructor.
WS_EX_CLIENTEDGE will give you the 3D look you don't want. I only mentioned CreateEx earlier because you were using WS_EX_CLIENTEDGE with Create.
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Yes Victor it is within the parent
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
Yes Victor it is within the parent
How did you check it is "within the parent"? Did you call GetWindowRect for both the parent and child to be sure they somehow intersect?
Or did you use some other way? Which one?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
I used the below code for creating CEdit dynamically, code compiled but editbox is not visible on screen.
Code:
CEdit *tedit = new CEdit;
tedit->CreateEx(WS_EX_CLIENTEDGE , L"Edit", L" ", ES_AUTHOSCROLL | WS_BORDER | WS_VISIBLE | WS_CHILD , CRect(15,150,30,20),this, IDC_EDIT);
BTW, did you check the CreateEx returned TRUE?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
VictorN
BTW, did you check the CreateEx returned TRUE?
It's not displaying because his CRect arguments are wrong. The bottom is higher than the top.
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
CreateEx is returning true..I have wrote this code inside OnInitDialog() function. Does any effect of it ..Any specific message handler to be used ?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
CreateEx is returning true..I have wrote this code inside OnInitDialog() function. Does any effect of it ..Any specific message handler to be used ?
Have you read the GCDEF's post (#24)?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
I read but getting no clue how to fix that.if i am able to see it anywhere on the dialog than atleast i will move it where i want .. within OnInitDialog() i wrote CRect temp; GetWindowRect(&temp); while debugging i got following values [ LT(108,1), RB(712,724)],[656 × 723]. So now accordingly please suggest any rough CRect() coordinates so that editbox get atleast visible
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
I read but getting no clue how to fix that.if i am able to see it anywhere on the dialog than atleast i will move it where i want .. within OnInitDialog() i wrote CRect temp; GetWindowRect(&temp); while debugging i got following values [ LT(108,1), RB(712,724)],[656 × 723]. So now accordingly please suggest any rough CRect() coordinates so that editbox get atleast visible
No clue how to fix it? Look at the parameters you need to pass in to a CRect constructor and see if the ones you're passing in make sense. You need to figure that one out yourself. I gave a good clue a few posts back.
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Hitting my trials since last 1 day, but not able to see CEdit on Screen. Below is the code of .rc file
[CODE]
IDD_DIALOG_M 0,0,283,277
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "MYDIALOG"
FONT 8,"TAHOMA"
BEGIN
PUSHBUTTON "OK" 15,251,37,15
END
[/ CODE]
Below is the code in .cpp for constructor and OnInitDialog
Code:
MyCDialog::MyCDialog( MyClass *acct, CWnd* pParent):CDialog(MyCDialog::IDD,pParent)
{
m_acct = acct;
}
BOOL MyCDilaog::OninItDialog()
{
CDialog::OnInitDialog():
m_edit = new CEdit; // CEdit *m_edit declared in .h
m_edit->CreatEx(!WS_EX_CLIENTEDGE , L"EDIT",L" " ,WS_BORDER | WS_VISIBLE | WS_CHILD, CRect(40,120,40,30), this, IDC_EDIT);
return TRUE;
}
Please help me out in passing correct values inside CRect so that box become atleast visible on screen
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
Hitting my trials since last 1 day, but not able to see CEdit on Screen. Below is the code of .rc file
[CODE]
IDD_DIALOG_M 0,0,283,277
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "MYDIALOG"
FONT 8,"TAHOMA"
BEGIN
PUSHBUTTON "OK" 15,251,37,15
END
[/ CODE]
Below is the code in .cpp for constructor and OnInitDialog
Code:
MyCDialog::MyCDialog( MyClass *acct, CWnd* pParent):CDialog(MyCDialog::IDD,pParent)
{
m_acct = acct;
}
BOOL MyCDilaog::OninItDialog()
{
CDialog::OnInitDialog():
m_edit = new CEdit; // CEdit *m_edit declared in .h
m_edit->CreatEx(!WS_EX_CLIENTEDGE , L"EDIT",L" " ,WS_BORDER | WS_VISIBLE | WS_CHILD, CRect(40,120,40,30), this, IDC_EDIT);
return TRUE;
}
Please help me out in passing correct values inside CRect so that box become atleast visible on screen
Let's start simple. What are the arguments the CRect constructor takes?
FWIW, the resource editor is much easier than doing it this way
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
CRect is taking (int l, int t, int r , int b).. from resource editor how can i do CreareEx()?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
CRect is taking (int l, int t, int r , int b).. from resource editor how can i do CreareEx()?
Now look at the numbers you're passing in. Do they make sense?
If you use the dialog editor, you don't need to call any kind of create. And again, you don't need CreateEx. I only mentioned it previously because you were using an extended style. The extended style is what is causing you problems.
I used the toolbox and dragged an edit control onto a dialog. Making no changes, it looked exactly like what you wanted.
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
If u will use the resource editor ,than edit box will look fine there but as soon as you will compile and see dialog on screen than sunken raised rdge(WS_EX_CLIENTEDGE) will be seen in CEdit.thats why i have to use CreateEx with !WS_EX_CLIENTEDGE .
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
If u will use the resource editor ,than edit box will look fine there but as soon as you will compile and see dialog on screen than sunken raised rdge(WS_EX_CLIENTEDGE) will be seen in CEdit.thats why i have to use CreateEx with !WS_EX_CLIENTEDGE .
I don't see that behavior. You can turn WS_EX_CLIENTEDGE off in the resource editor, but it shouldn't be on anyway. WS_BORDER and WS_VISIBLE should be all you need. What version of Visual Studio are you using?
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Visual studio 2015..I have turned client edge off
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
I can't tell you anything else at this point. Maybe zip up the smallest project you can so we can take a look.
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Quote:
Originally Posted by
Beginner_MFC
I suggest you the third time: use Spy++ to ensure all the window as well as the extended window styles of the editbox you want to create. :cool:
-
Re: How to do flat style of CEdit (EDITTEXT) and CComboBox in CDialog
Passing right parameters to CRect (left, top,right,bottom) resolved it. Width = right - left , Height = bottom- top.