|
You should post the question in the more appropriate Managed C++ / CLI [^] forum.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
So I am working on an app, and it requires tons of Variable Declarations, which I dont want them all in my main.cpp view port, it would be too crowded, is there a way to store them in a different file as a list and call them when I need to, for a user to input or to read static vars? This also goes for VB too. I.E:
Main.cpp
--------
int _tmain(){
cout << "Name: "; cin >> userName;
}
external file
--------
string userName;
string userName1;
string userName2;
|
|
|
|
|
You can put all the variable declarations in a header file and #include it in the main.cpp file.
But, if you #include this header in multiple cpp files you will get a multiple declaration linker error.
In such cases, declare all variables in a separate .cpp file.
To use these variables in some other .cpp file like main.cpp, declare the same variables as extern in the main.cpp file.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
so its safe to put a struct() in a header and it will store information to the decl vars in the structure from the main.cpp?
|
|
|
|
|
Yes, you can do that, for instance, in decl.h :
std::string username;
...
and then in main.cpp :
#include "decl.h"
You may also, if it makes sense, make the variables member of a class (or of a namespace).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Herboren wrote: sweet
home Alabama?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I made this codes on OnPaint() function:
CPaintDC dc(pdlg);
CFont font;
font.CreateFont(
24,
0,
0,
0,
FW_HEAVY,
true,
true,
0,
DEFAULT_CHARSET,
OUT_DEVICE_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY ,
FF_SCRIPT ,
"Times New Roman");
dc.TextOut(15, 100, "welcome", 7);
dc.SelectObject(&font);
font.DeleteObject();
Text is appear on dialog form, but it is still on regular style and using arial font type.
Whereas, I have set that font to Italic-underline style. I also changed font facename to Times New Roman and Verdana, but there is no differences when it show on dialog form.
What's wrong with my codes? Is there any missing code?
Help me please...
Thanks and Regards,
modified on Monday, September 28, 2009 2:56 AM
|
|
|
|
|
Try putting the line dc.SelectObject before the line dc.TextOut .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
thank you <<_Superman_>>...
My problem is solved...
Thanks a lot..
|
|
|
|
|
Your problem may be solved, but you may have made another one.
You are keeping the return value of SelectObject, and Selecting it back in later on aren't you?
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need contract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hi all,
Please help me, how to change color and font of push button in visual C++ 6.0?
Any reference that I can learn?
I used dialog based project.
thanks and regards,
|
|
|
|
|
|
I have tried using this codes:
HBRUSH CGambarDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if( pWnd->GetDlgCtrlID() == IDC_BUTTON1 )
{
pDC->SetBkColor( RGB( 255, 0, 0 ));
pDC->SetBkMode( TRANSPARENT );
}
return hbr;
}
but, nothing changes happened...
that codes is not correct?
|
|
|
|
|
If you read the remarks section of the document, it says that button with certain styles always use the default colors. In such cases, you would need an owner draw button.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thank you for your answers.
Sorry if I confiscating your time. But, I still confuse.
I have read the documents and link to using button on MSDN when I clicked owner-drawn button.
Is it right that these changes possible to do if I use it on Win32App project, not a MFCApp(.exe)?
I have no idea, where I should used this message (WM_CTLCOLORBTN) in Dialog Based Project.
I looked for WM_CTLCOLOR on parent window, I just found OnCtlColor(^).
Please give me explanations.
Thanks a lot.
|
|
|
|
|
Eka Candra wrote: Is it right that these changes possible to do if I use it on Win32App project, not a MFCApp(.exe)?
Of course.
Eka Candra wrote: I looked for WM_CTLCOLOR on parent window, I just found OnCtlColor.
MFC maps the OnCtlColor method to the WM_CTLCOLOR message.
So you just need to write your code into the OnCtlColor method.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Eka Candra wrote: but, nothing changes happened...
Is OnCtlColor() called?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
?????????
WM_CTLCOLORBTN has never been for buttons !
Use either OD button or Undocumented Shell buttons.
|
|
|
|
|
Hi there
I want to create a modeless dialog but have it act like a child window (never gets out of my client area, moves with my window, etc) of a MDI Frame window. The dialogs must stay within the MDIClientWnd of the main frame.
I need to create several children like that all based on different dialog templates.
So, I dont want to use CFormViews as I will have to create several documents and children frames.
Any suggestions?
THanxx guys
NAngelGr
|
|
|
|
|
I believe creating documents and views will be easier and more straight forward than what you're trying to do here.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I agreed with u, and the CFormView is a plus.
|
|
|
|
|
Hi,
I am looking for an experienced DirectX 10 programmer who could be able to create code for terrain, water and the sky. A team of programmers have already built the foundation of the game as now we just need to start working with DirectX.
Thanks
Andrew McIntyre
|
|
|
|
|
This is a forum for technical questions. If you need to advertise, then please use the proper channels; even though it may cost you money.
Please read and abide by these guidelines[^].
|
|
|
|
|
MrMcIntyre wrote: I am looking for an experienced DirectX 10 programmer
And I need a cup of coffee.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|