|
Did a quick search on MSDN, and found the following article:
Trackbar Controls[^]
Scrolling down, it tells you about the notification messages. It behaves just like a scroll bar, and sends WM_HSCROLL, or WM_VSCROLL as appropriate.
You will want to use WM_xSCROLL / TB_ENDTRACK. It is sent when you use both keyboard and mouse.
I hope this puts you on the right path,
Iain.
|
|
|
|
|
How to set display resolution (800*600,1024*...) in runtime?
|
|
|
|
|
Use ChangeDisplaySettings .
Refer this article by maciejr[^]
|
|
|
|
|
DEVMODE ESimSetDM;
EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &ESimSetDM);
if( (ESimSetDM.dmPelsWidth != 800) || ( ESimSetDM.dmPelsHeight != 600))
{
ESimSetDM.dmPelsWidth = 800;
ESimSetDM.dmPelsHeight = 600;
ChangeDisplaySettings( &ESimSetDM,CDS_UPDATEREGISTRY );
}
this code will always keep the Display settings as 80*600:->
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
Hi
What does the meaning of keyword "const" in the following declaration
CString GetItemText(int nRow, int nCol) const;
pls give a help
Thanks
SYAMLAL
|
|
|
|
|
SyamlalS wrote: CString GetItemText(int nRow, int nCol) const;
This means GetItemText function does not modify any of the member variables of the class to which this function belongs niether does it call any member function that modifies any member variables of the said class.
|
|
|
|
|
Will it cause any kind of errors if I take the return value to a CString variable??
SYAMLAL
|
|
|
|
|
SyamlalS wrote: Will it cause any kind of errors if I take the return value to a CString variable??
No. The const declaration of the function has nothing to do with its return value.
|
|
|
|
|
Nibu babu thomas wrote: This means GetItemText function does not modify any of the member variables of the class to which this function belongs niether does it call any member function that modifies any member variables of the said class.
EXCPETION: mutable data members can be changed by const member functions.
Steve
|
|
|
|
|
SyamlalS wrote: CString GetItemText(int nRow, int nCol) const;
This function does not change state/value of member variables of class, it is function of.
|
|
|
|
|
In addition to what Prasad and Nibu babu thomas already said...
Consider the const keyword as a promise to the compiler that you won't change the value of the variable. If you don't honour this promise the compiler will remind you of it. This applies in al situations for the use of the const keyword.
SyamlalS wrote: CString GetItemText(int nRow, int nCol) const;
If you try to alter member values inside a member function declared as const , you'll get a compiler error.
So what is the benefit of the const keyword in this situation?
The answer is that you can call such functions on a const declared object.
Explanation in code:
class CMyClass
{
public:
int GetValue() { return m_nValue; }
int GetValueConst() const { return m_nValue; }
};
void UseClass( const CMyClass theClass )
{
int nTheValue;
nTheValue = theClass.GetValue();
nTheValue = theClass.GetValueConst();
}
It's considered good practice to declare member functions that don't alter any member variables as const .
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: nTheValue = theClass.GetValue(); // Compiler error
Exactly how is this modifying a member variable?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Roger Stoltz wrote: nTheValue = theClass.GetValue(); // Compiler error
DavidCrow wrote: Exactly how is this modifying a member variable?
I never said it would and the code also shows that it doesn't.
The compiler error is due to the instance of CMyClass being a constant object and the CMyClass::GetValue() member function is not declared as constant.
I posted it as an explanation for the use of this syntax.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
in addition, such a constness concerning a member function is allowed to modify a data member if and only if it was declared mutable .
|
|
|
|
|
class sample
{
CString s1;
mutable CString s2;
public:
CString GetItemText(int nRow, int nCol) const;
};
CString sample::GetItemTextint nRow, int nCol) const;
{
s1 = _T("abc");//error because an const function can't change the data memter
//They are only for accesing
s2 = _T("abc");//works the keyword mutable is given
return s1;
}
//U have to read more on const object too
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
Glad you mentioned that, because it is important and I have found that aspect very useful. Although that ability needs to be used with great care and forethought, as it can easily be misused.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi,
I need to have a radio button inside the list control. The radio button should have the background color as white.
How can i do this ?
Thanks.
|
|
|
|
|
|
Hi everybody!
I wrote a code to display a messagebox when WM_QUERYENDSESSION message is posted.This is the code i wrote!
bool CMainWnd::OnQueryEndSession()
{
MessageBox(NULL,"QueryEndSession message is posted",MB_OK);
}
Is this correct! I expected to get a messagebox when i wanted to logoff the system. But it didnt work!Is anything wrong with my code!If so,I humbly request you to respond me!
Thanks in advance!
Regards
Shalini
-- modified at 6:55 Friday 2nd March, 2007
|
|
|
|
|
ShaluMalu wrote: Is anything wrong with my code
No.
Are yo sure ON_WM_QUERYENDSESSION() is there is message map.
|
|
|
|
|
Hi All.
I have problem, in my program I use 4 thread and thay all use:
<br />
<br />
wchar_t* MyFolder(wchar_t* pSearch)<br />
{<br />
wchar_t Folder[2048]= {L'\0'};<br />
size_t n=0; <br />
<br />
wcscpy(Folder,pSearch);<br />
<br />
for(n=wcslen(Folder); n >= 0; n--)<br />
if(Folder[n] == L'\\')<br />
{<br />
Folder[n+1]=L'\0';<br />
break;<br />
}<br />
<br />
return Folder;<br />
}
this function, and wen I debug it, I olvais have problem to this function.
I think thare is one of two:
1) I have not much experience
2) I do some mistake [in threads or in this function].
can help?
|
|
|
|
|
Read about CCriticalSection on MSDN
Regards
Anil
|
|
|
|
|
david bagaturia wrote: wchar_t Folder[2048]= {L'\0'};
david bagaturia wrote: return Folder;
Folder goes out of scope when the function exits so you should not return a pointer to that memory. Allocate the memory using new() or allocate the buffer in the calling function and pass it to this function
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
As indicated by Josh, the problem is because, you are returning address of local object. Create it on heap, and return it.
david bagaturia wrote: for(n=wcslen(Folder); n >= 0; n--)
This is in fact very bad coding practice, It causes unnecessary multiple calls of a functions.
Modify it to,
size_t n =wcslen(Folder);
for(n; n >= 0; n--)
-- modified at 9:07 Friday 2nd March, 2007
|
|
|
|
|
prasad_som wrote: It causes unnecessary multiple calls of a functions.
Actually it doesn't. wcslen() is only called once.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|