|
Hey all,
I've got an application running the XP Style interface where the scroll bars are nicely shaded, buttons are highlighted, etc. However, in any CWnd derived class, if I call ShowScrollBar(), the scroll bar will still look like the old pre-XP style scroll bar. However, this problem does not happen in common MFC classes like CScrollView or CListCtrl - only my own CWnd classes. It looks horrible when the rest of my app is in the XP style look. Any suggestions?
To reproduce the problem, I think all one needs to do is create a new CWnd somewhere and call ShowScrollBar(). It will sport the old look, rather than the new XP look.
EDIT: I solved this problem. If anyone is interested, such behavior occurs when ShowScrollBar() is called before SetScrollRange() or SetScrollInfo() is called to set up the non-client scrollers.
|
|
|
|
|
Do you find that if you call SetScrollInfo and specify the nPage size in the structure to resize the thum, the scroll bar doesn't scroll all the way to the max value?
I can't find the correct way to fix this other than changing the max value.
|
|
|
|
|
Hello there,
I have a problem with the order of how folders and files are listed when I use CFileDialog-class.
Normally when calling the box, it first lists all folders then all files (in alphabetic order).
For some days now the order is reversed. So first all the files THEN all the folders. I can change the order each time with help of the "options" button (==> Show Details ==> then click on "Name") but I have to do that each time I use the CFileDialog in my program.
Actually the same thing already happens in only AOME of my windows programs (e.g. in Netscape yes but in Word not...)
Anybody any idea?? Any help or hint is appreciated!
Kai
Kai
|
|
|
|
|
I have some utility functions that I would like to put into a library. I want the library to be used like you would for example the cos(x) function from the math library.
All you have to do is include the header
#include <math.h>
Then you can use the function
float result = cos(somenum);
How do you accomplish this?
|
|
|
|
|
Create a static library project containing your utility functions (menu File->New->Project, choose Visual C++ Projects, then select the template Win32 Project. Finally in the wizard, select the Static Library option). Once compiled your will get one .h and one .lib file, which you can include within your other projects.
|
|
|
|
|
Thanks for the response. I will try that once I get a moment.
Will I need to extern "C" the functions or anything else special?
|
|
|
|
|
To make a utility function in a library available for use, you need something like the following in your .h file:
extern "C"
{
declspec(dllexport) void MyFunc(int i);
}
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
|
Hi,
I want to know how can I power on a computer in a network?
Cheers,
Thanks.
|
|
|
|
|
search WAKE ON LAN on google
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Imagine a situation in which Dialog Box added to TabCtrl is bigger. Than I think TabCtrl should provide a scrollbar. But I am not getting any ScrollBar. So what might be the problem. Is it by default or I have to set some properties.
Thanks
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
Bahadur - yar - Jung wrote:
hich Dialog Box added to TabCtrl is bigger. Than I think TabCtrl should provide a scrollbar.
Yeap It is Default, TabCtrl resize dialog box according to it size .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Thanks for replyieng.
I tried a simple sample program and I am not able to see both horizontle and verticle scrollbars. I mean they are not visible by default. Do I need to enable certain properties ?
Thanks again.
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
ok ! could some one quide in this :- we have game project where each room is currently run by running the same game server application for each room , in other words for multiple rooms multiple instances of same game server exe are run . Because threads are not used it takes more memory if we need to run large number of rooms by running the same server exe number of time equlal to the rooms .
The current application is developed in a single dialogue box which has all the code and which manages the sockets . now we need to make whole thing in single game server application using threads to run numtiple rooms within . so can some one tell that , can we use the current version and us it into new appication and have it run the same code into new threads to add new room each time and will we need to make the application communicate from one main port or can we have the old code run in new thread and let it open an unique port for ecah room .
What would be a right approach to making such an application which can run 500 such rooms in other words 10000 concurrent users as each room have 10 live players .
|
|
|
|
|
Respected Dears
How i can write code for Static text control at run time.
david
|
|
|
|
|
Assuming you are using MFC:
- Add CStatic *m_pMyStatic as member of your CWnd(-derived) object
- When it is required, create the control:
m_pMyStatic = new CStatic;
m_pMyStatic->Create(...);
m_pMyStatic->SetWindowPos(...);
etc. - Don't forget to delete the control when it is no longer needed (for instance in the destructor):
delete m_pMyStatic;
|
|
|
|
|
Hello,
There is an exe that:
1.I want to send this file to a client from server but that client haven't the client program.How?
2.How to run (Install) this file?
Cheers,
Thanks.
|
|
|
|
|
Respected All
Regards!
How i can write Code for Creating STATIC TEXT control at RunTime.
best wishes
david
|
|
|
|
|
Good Morning everybody,
i'd like to get your help on that too deep problem for my mind for the moment i am reflecting on.
I have a Dialog based MFC project that i am programming on VS7.1.
It's been compiling well, and i can execute it well as far as i enter in a certain state that causes the crash (so, if there is any syntactic/writing mistake on the code exposed, it is only on this post i make an error - as i don't Copy/Paste all the code given here).
i have two main classes, plus some extra types defined outside the classes as they are used by the two classes :
<code>CFactEditorDlg</code> (the main dialog of the program)
- FactEditorDlg.h
- FactEditorDlg.cpp
<code>COptionsDlg</code> (the option dialog of the program, that allow the user to set some display parameters)
- OptionsDlg.h
- OptionsDlg.cpp
FactEditorTypes.h (sample) :
<font color=blue>typedef enum</font> {
<font color=green>
} TStartingCallCountry;
<font color=blue>typedef enum</font> {
<font color=green>
} TEditorLanguage;
<font color=blue>typedef unsigned char</font> TDigitsInYears;
<font color=blue>typedef unsigned char</font> TDigitsInPhones;
<font color=blue>typedef struct</font> {
TStartingCallCountry _StartingCallCountry;
TEditorLanguage _EditorLanguage;
CString _FileViewer;
TDigitsInYears _NbDigitsInYears;
TDigitsInPhones _NbDigitsInPhones;
} TEditorOptions;
TEditorOptions is a type made to transfer the 5 fields it encapsulates from CFactEditorDlg to the COptionsDlg , and to get them back (maybe modified) then.
This is done in the OnSclickOptions button as follow :
<font color=blue>void</font> CFactEditorDlg::OnSClickOptions() {
<font color=green>
TEditorOptions EditorOptions = {
m_StartingCallCountry,
m_EditorLanguage,
m_strFileViewer,
m_ucNbDigitsInYears,
m_ucNbDigitsInPhones
};
<font color=green>
COptionsDlg OptDlg(EditorOptions, m_strEditorVersion, <font color=blue>this</font>);
<font color=blue>int</font> iResult = OptDlg.DoModal();
<font color=blue>if</font> (iResult == IDOK) {
<font color=green>
<font color=green>
}
<font color=blue>else</font> { <font color=green>
}
}
...and here is how the constructor of COptionsDlg treats the TEditorOptions parameter :
COptionsDlg::COptionsDlg(TEditorOptions& EditorOptions,
CString EditorVersion,
CWnd* pParent <font color=green></font>)
: CDialog(COptionsDlg::IDD, pParent),
m_EditorOptions(EditorOptions) <font color=green>
{
::strcpy(m_strEditorVersion, EditorVersion);
<font color=red>m_strEditorVersion = EditorVersion</font>; <font color=green>
m_strDigitsInYears.Format(<font color=gray>"%d"</font>, m_EditorOptions._NbDigitsInYears);
m_strDigitsInPhones.Format(<font color=gray>"%d"</font>, m_EditorOptions._NbDigitsInPhones);
}
now, the problem is that the Options dialog modifies well the datas, returns them to the CFactEditorDlg::OnSClickOptions() event handler correctly (i displayed the resulting values with a MessageBox), but just when i get out the OnSClickOptions() function, i get such a weird error :
Run-Time Check Failure #2 - Stack around the variable 'EditorOptions' was corrupted.
this is exactly what i get from the Run-Time, and i really can't understand what it can mean.
if it is of any help, i tried to see what happens in the debugger, and i saw that the local EditorOptions (local to OnSClickOptions() ) is staying with the values it got from the option dialog, except the fact that the CString member _FileViewer is leaving its content.
the debbugger gives this :
Before :
_FileViewer {0x002fa000 "notepad"} ATL::CStringT<char,StrTraitMFC_DLL<char,ATL::ChTraitsCRT<char> > >
After :
_FileViewer {0x002fa000 "îþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþ"} ATL::CStringT<char,StrTraitMFC_DLL<char,ATL::ChTraitsCRT<char> > >
if anybody knows, i'm all listening at you guys...
[edit]
i modified the m_strEditorVersion in both DialogBox classes into CString.
The error remains the same...
[/edit]
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
Run-Time Check Failure #2 - Stack around the variable 'EditorOptions' was corrupted.
This means that some variable on your stack was overflowed or underflowed. Also that the program asserts when you leave the handler indicates that that the stack is corrupted in that function, not in the DoModal .
toxcct wrote:
::strcpy(m_strEditorVersion, EditorVersion);
I think that the problem is here. You call un unsafe C function on a variable with an uninitialized length! If my assumtions are correct, m_strEditorVersion is of type CString .
If I'm correct, see what the following gets you:
::strncpy(m_strEditorVersion.GetBufferSetLength(256), EditorVersion, 255);
m_strEditorVersion.ReleaseBuffer();
Your problem was because you were writing to a CString buffer that had a size which was too small. A better solution would be:
COptionsDlg::COptionsDlg(TEditorOptions& EditorOptions, <br />
CString EditorVersion,<br />
CWnd* pParent )<br />
: CDialog(COptionsDlg::IDD, pParent),<br />
m_EditorOptions(EditorOptions),
m_strEditorVersion(EditorVersion) <br />
{
m_strDigitsInYears.Format("%d", m_EditorOptions._NbDigitsInYears); <br />
m_strDigitsInPhones.Format("%d", m_EditorOptions._NbDigitsInPhones);<br />
}<br />
May I ask why you use ::strcpy to copy CString contents?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote:
m_strEditorVersion(EditorVersion)
{ // or just try:
// m_strEditorVersion = EditorVersion;
in fact, i did this first, but the compiler told me to put this in the constructor initialization list...
Bob Stanneveld wrote:
May I ask why you use ::strcpy to copy CString contents?
i do ::strcpy(m_strEditorVersion, EditorVersion); because m_strEditorVersion is defined as a char[10] ...
so, the code you suggest me with ReleaseBuffer() won't be able to work...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
i do ::strcpy(m_strEditorVersion, EditorVersion); because m_strEditorVersion is defined as a char[10]...
so, the code you suggest me with ReleaseBuffer() won't be able to work...
Your naming convention is a little bit misleading. m_strEditorVersion suggests that is is a normal string instead of a C-Style string. Use m_pszEditorVersion instead.
Back to the problem. Did you check the length of the EditorVersion string? You are just copying the string without length checking. This is a horrible mistake! You should use ::strncpy and copy up to 10 characters if you don't care about the '\0' or only 9 and set the NULL-terminator yourself. I'm almost 100% sure that this solves your problem.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
eBob Stanneveld wrote:
Did you check the length of the EditorVersion string? You are just copying the string without length checking
currently, yes you're right, but as i use the debugger to confirm, m_strEditorVersion is a char[10] and contains only "2.10" (correctly terminated with its trailing '\0' character)...
well, i'll test the changes on the afternoon, but now, i dont have enough time to tell you if the changes are useful or not. however, i think i'll change the char[10] to a CString, regardless to the memory occupied...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Do you still get the error with the range checking code?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
hi bob, i'm back
i've edited my first post on this thread... the error remains the same, even when i changed the m_strEditorVersion into CString...
i think it is not the source of the problem because the Run-Time talks about TEditorOtions ...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|