|
yes, you can put them in a namespace, and it's good style to do so.
to declare:
namespace myNameSpace
{
bool globalBool;
CMyObject globalObject;
...
};
...
to use:
myNameSpace::globalBool = false;
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
|
Just a little addition to previous replies , if you don't want to write
myNameSpace::SomeFunction() every time you call it, then you can add following line to your main() function :
using namespace myNameSpace;
And then you will be able to directly call SomeFunction() in main();
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
karmendra_js wrote:
Also I don't know how to create and use namespace.
Name Space[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi,
Yes you can locate global variables in namespaces.
The importance of doing so depends on the specific case.
For example, if you are afraid your var's name could
conflict with another var's name, put yours in a namespace.
Another example, if you have many global variables (hope
you don't) you'd rather put them in a namespace in terms of
'well organization'.
Code:
namespace Globals
{
bool bVar1;
bool bVar2;
// any others...
} // namespace Globals
Now let's use it:
// method 1. (not preferred)
using namespace Globals;
void f()
{
bVar1 = false;
}
// method 2. (less preferred)
using Global::bVar1
void f()
{
bVar1 = false;
}
// method 3. (ok)
void f()
{
Globals::bVar1 = false;
}
|
|
|
|
|
Hi,
I want to disable multiple row select in a list control. It should select only one row at a time how can i do this.
Thanks
|
|
|
|
|
In design view select list control properties->styles->single selection
check this box , u r job is done !
Muthu Ramji.Al.V
Software developer(VC++)
Sify Limited
muthu_ramji@sifycorp.com
|
|
|
|
|
I want to do it programatically. It is in LVS_REPORT style.
What you are saying is for ListBoxCtrl.
Thanks
|
|
|
|
|
Dear friend,
if u have 2 do in code then try this,
1.
//-------- Start create a list control using dwstyle LVS_SINGLESEL
CListCtrl* pmyListCtrl=new CListCtrl;
pmyListCtrl->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT|LVS_SINGLESEL ,CRect(10,10,300,200), this, 1);
//---------
2.same can be done with visual design mode as i said earlier. Both in list box & list control v have that check box. Kindly check in property dialog box
3.if u want i will help with a demo program
|
|
|
|
|
does somebody knows how to use this function
I know that it gets 7 param ,
but the weird thing is that theres is no other function to receive the File
something like ReceiveFile , there is no other function, sooo
how can I receive the transmited file ??????????????????
so how can I receive the file ??
I need to transfer one file through a sockte,,
the socket is working right , I can send and receive with functions
send () , and recv ()
but I want to know the ease way to transfer a file,,
can somebody help me ???
THANX
GOD BLESS YA
REU
|
|
|
|
|
I meet problem about read and write file
my email is fisheryj@gmail.com
----------------------------
Jerry yu
Chinese
programming fans
|
|
|
|
|
|
|
Jerry yu wrote: I meet problem about read and write file
And what exactly would that problem be?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I use vc++ just several times .I use Delphi before .
So I hope some one to help me .Because mfc is too difficult for me
thx
----------------------------
Jerry yu
Chinese
programming fans
|
|
|
|
|
Which function can I use in VC6?
Prompt : there are not the CHS parameters for USB flash disk .
|
|
|
|
|
I have used a date time control in my
project which i need to get the date from
teh user ,
I get everthing fine but the date retrived
is wrong.When again i select the same date
i get the date write by the same code .
Has anyone faced such problem.
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I couldnt exactly get your problem. Maybe you should call UpdateData(FALSE) before using the associated variable.
"Do first things first, and second things not at all."
— Peter Drucker.
|
|
|
|
|
The NULL Developer wrote:
Maybe you should call UpdateData(FALSE) before using the associated variable.
Just a little Correction.. there is no need of use UpdateData(FALSE) on CDateTimeCtrl
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thank you Alok
in the MSDN samples just search for floder named "cmnctrl1"
open the project and in the file "datetime.cpp" replace the function as below
<br />
<br />
<br />
void CDateTimePage::OnDTNotify(NMHDR *pHdr, LRESULT * pRes)<br />
{<br />
CTime ct;<br />
CString st;<br />
<br />
switch( pHdr->code)<br />
{<br />
<br />
case DTN_CLOSEUP:<br />
m_lbNotifyList.AddString(_T("DTN_CLOSEUP"));<br />
<br />
break;<br />
case DTN_DATETIMECHANGE:<br />
<br />
m_lbNotifyList.AddString(_T("DTN_DATETIMECHANGE"));<br />
(m_DateTime.GetMonthCalCtrl())->GetCurSel(ct);<br />
ct.GetMonth ();<br />
m_DateTime.UpdateData (TRUE);<br />
st.Format(_T(" --- %02d/%02d/%2d ---%2d"),ct.GetMonth(),ct.GetDay(),ct.GetYear(),((ct.GetDay())-12 ));<br />
m_lbNotifyList.AddString(st);<br />
break;<br />
<br />
case MCN_SELECT:<br />
m_lbNotifyList.AddString(_T("asdf"));<br />
break;<br />
<br />
case DTN_DROPDOWN:<br />
m_lbNotifyList.AddString(_T("DTN_DROPDOWN")); <br />
break;<br />
case DTN_FORMAT:<br />
m_lbNotifyList.AddString(_T("DTN_FORMAT"));<br />
break;<br />
case DTN_FORMATQUERY:<br />
m_lbNotifyList.AddString(_T("DTN_FORMATQUERY"));<br />
break;<br />
case DTN_USERSTRING:<br />
m_lbNotifyList.AddString(_T("DTN_USERSTRING"));<br />
break;<br />
case DTN_WMKEYDOWN:<br />
m_lbNotifyList.AddString(_T("DTN_WMKEYDOWN"));<br />
break;<br />
}<br />
<br />
}<br />
The code in between the //->---- ... ... . //->-----
is added by me actully according to the theory it should display
the data in the datetime control but it displays a wrong date that
is 12 days before .
I found a solution to directly get the text from the date time control
with GetWindowText ();
but i have to parse it by my self & cannot use the direct function like GetMonth(),GetDay(),GetYear(),etc.
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
vikas amin wrote:
I found a solution to directly get the text from the date time control
with GetWindowText ();
What about calling
DWORD CDateTimeCtrl::GetTime(
CTime& timeDest
) const;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
actually alok
I have used DateTime control as an acitveX in my MFC project.
the control is placed on on DialonBar
I got the handle to the control by using this code
CWnd* pCtrl1 = m_dlgbar.GetDlgItem(IDC_DTPICKER1);
ASSERT(pCtrl1 != NULL);
Then i tried to get the text from the Datetime control by using the
code
pCtrl1->GetWindowText (st);
but it retives not data .Do u hav any idea why
i tested this code on a Dlgbase project
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
i actully wanted to get the window text of a control
so i created a pointer to that control .
CDateTimeCtrl * pwnd =(CDateTimeCtrl *) m_dlgbar.GetDlgItem(IDC_DATE_PICKER);
now i tired to get the window text by this but
CString st;
pwnd->GetWindowText (st);
I dont understand why this dont work ..........
do u have any idea.
Yeh actuly i got the date and time by using the
pwnd->GetTime(ct);
Thank u
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
vikas amin wrote: I get everthing fine but the date retrived
is wrong.
What do you mean by "wrong?" What does the code look like?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thank you David
in the MSDN samples just search for floder named "cmnctrl1"
open the project and in the file "datetime.cpp" replace the function as below
<br />
<br />
<br />
void CDateTimePage::OnDTNotify(NMHDR *pHdr, LRESULT * pRes)<br />
{<br />
CTime ct;<br />
CString st;<br />
<br />
switch( pHdr->code)<br />
{<br />
<br />
case DTN_CLOSEUP:<br />
m_lbNotifyList.AddString(_T("DTN_CLOSEUP"));<br />
<br />
break;<br />
case DTN_DATETIMECHANGE:<br />
<br />
m_lbNotifyList.AddString(_T("DTN_DATETIMECHANGE"));<br />
(m_DateTime.GetMonthCalCtrl())->GetCurSel(ct);<br />
ct.GetMonth ();<br />
m_DateTime.UpdateData (TRUE);<br />
st.Format(_T(" --- %02d/%02d/%2d ---%2d"),ct.GetMonth(),ct.GetDay(),ct.GetYear(),((ct.GetDay())-12 ));<br />
m_lbNotifyList.AddString(st);<br />
break;<br />
<br />
case MCN_SELECT:<br />
m_lbNotifyList.AddString(_T("asdf"));<br />
break;<br />
<br />
case DTN_DROPDOWN:<br />
m_lbNotifyList.AddString(_T("DTN_DROPDOWN")); <br />
break;<br />
case DTN_FORMAT:<br />
m_lbNotifyList.AddString(_T("DTN_FORMAT"));<br />
break;<br />
case DTN_FORMATQUERY:<br />
m_lbNotifyList.AddString(_T("DTN_FORMATQUERY"));<br />
break;<br />
case DTN_USERSTRING:<br />
m_lbNotifyList.AddString(_T("DTN_USERSTRING"));<br />
break;<br />
case DTN_WMKEYDOWN:<br />
m_lbNotifyList.AddString(_T("DTN_WMKEYDOWN"));<br />
break;<br />
}<br />
<br />
}<br />
The code in between the //->---- ... ... . //->-----
is added by me actully according to the theory it should display
the data in the datetime control but it displays a wrong date that
is 12 days before .
I found a solution to directly get the text from the date time control
with GetWindowText ();
but i have to parse it by my self & cannot use the direct function like GetMonth(),GetDay(),GetYear(),etc.
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|