|
thanku for ur reply..
i have created a structure having
CString and int values like this
struct test
{
CString str;
int item;
};
created its object like this
test *obj;
obj = new test;
and in that object passed the values
like
obj->str = "neha";
obj->item = 1;
After that i have started thread like this
Ping = AfxBeginThread(PingThread,obj);
in thread i have retrieved first Cstring value like this
cstrHost = *(static_cast<cstring*>(pParam));
but in my integer value i m getting garbage value..
int_val = *(static_cast<int*>(pParam));
How to correct it.....
|
|
|
|
|
test *pStruct = (test*)pParam;
cstrHost = pStruct -> str;
int_val = pStruct -> item; Just like with candy, you have to first get to the outer portion (i.e. the wrapper) in order to get to the good stuff inside.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi all,
I've just tried to bold the font in a particular static in one of my dialogs.
for this i have done this :
I Have 2 statics left aligned, containing exactly the same string (the upper one is for comparison purpose).
The static I modify has a control variable of type CStatic on it.
here is the code i put in the dialog's OnInitDialog() :
HDC hdc = (HDC)(*m_myStatic.GetDC());
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
int n = ::GetTextFace(hdc, 0, NULL);
TCHAR* pszFontName = new TCHAR[n];
::GetTextFace(hdc, n, pszFontName);
CFont nf;
nf.CreateFont(tm.tmHeight,
tm.tmAveCharWidth,
0,
0,
tm.tmWeight,
FALSE,
tm.tmUnderlined,
tm.tmStruckOut,
tm.tmCharSet,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
tm.tmPitchAndFamily,
pszFontName);
delete[] pszFontName;
m_myStatic.SetFont(&nf);
as you can see, i merely duplicate the original font without bolding it, but what a surprise, the static is bold anyway
can anyone explain me why the font (Tahoma) is acting like this ?
|
|
|
|
|
super_ttd wrote: CFont nf; nf.CreateFont(tm.tmHeight, tm.tmAveCharWidth, 0, 0, tm.tmWeight, FALSE, tm.tmUnderlined, tm.tmStruckOut, tm.tmCharSet, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, tm.tmPitchAndFamily, pszFontName);
You are creating a local CFont object. Hence the CFont object get's destroyed. This is the reason for this wierd behavior, might be since the font object got destroyed it's using DEFAULT_GUI_FONT.
From MSDN:
Specifically, do not destroy the specified CFont object until after the CWnd control has been destroyed.
Windows does not copy the font specified in a SetFont() call.
If the font is destroyed before the control is destroyed, unpredictable results can occur. "new" the font object and see the difference...
And by the way you don't have to write this much code for modifying an existing font object...
Here is the code snippet that does this...
CFont* pFont = m_cstc.GetFont();
LOGFONT lfLogFont = { 0 };
pFont->GetLogFont( &lfLogFont );
lfLogFont.lfWeight = FW_BOLD;
CFont pNewFont = new CFont;
pNewFont->CreateFontIndirect( &lfLogFont );
m_cstc.SetFont( pNewFont );
|
|
|
|
|
super_ttd wrote: can anyone explain me why the font (Tahoma) is acting like this ?
Don't make things any more complicated than necessary. See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi David, Thanks for answering.
but you know, i refered this exact post to initiate my test, and i found that the answers to this guy were far from being complete... see, i couldn't figure out myself the right way with your 3 replies there.
but thanks to Babu, I think I'm on the road again
|
|
|
|
|
super_ttd wrote: thanks to Babu
Nibu babu thomas.
|
|
|
|
|
hi,
i have created a active x control, after registering it i have included that ocx in my dialog based application.wen i right click the ocx control i get its properties in the design mode.Wen we click the property page icon of that control we get a dialog box containing general tab which constitutes the space for import folder and help folder how to use that property page???
zari
|
|
|
|
|
Hi I need to calculate the no of timers running in my aplication at any instants of time.I am only using timers initialize by SetTimer() function.
thanx in advance,
Birajendu
birajendu
CyberG India
Delhi
India
|
|
|
|
|
birajendu wrote: I am only using timers initialize by SetTimer() function.
Ok, so only respond to those in your handler function. Send the rest on to the default handler.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi
i want to create a project in visual studio 6 that contains multipe C source files and header files
but i cant understand how a file can access a function or a variable declared in the other file ?
and i want to know if its right to add #includes for the standard libraries in all files ?
thanks
|
|
|
|
|
Ayman Mashal wrote: but i cant understand how a file can access a function or a variable declared in the other file ?
What you need to do is provide a function prototype of your function that will be declared in your header file. Then the function body will be in the cpp file.
In the cpp file in which you would like to use this function, simply include the header file. If the function is defined somewhere in a cpp file, then the linker will do its job .
Ayman Mashal wrote: and i want to know if its right to add #includes for the standard libraries in all files ?
A good practice is to include only the files you need in your file.
|
|
|
|
|
Ayman Mashal wrote: i cant understand how a file can access a function or a variable declared in the other file ?
For functions, Cedric Moonen has answered you. For variables, look at the keyword extern for doing this.
Ayman Mashal wrote: i want to know if its right to add #includes for the standard libraries in all files ?
It is perfectly safe to #include the libraries in all the files, until they are guarded with #ifndef , #define and #endif to prevent it from being included multiple times.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
lets say that i have header.h file that contains types,variables,defines declarations
and that i have main.h file that include header.h file
and main.h is included in many source files .
now when i try to build the project i get that the variables in header.h already defined in the obj
file .
so how can i deal with this ?
thanks
|
|
|
|
|
You need to surround your header file with include guards. Something similar to this:
#ifndef MYFILE_H
#define MYFILE_H
... The code of your header comes here
#endif
You need to replace MYFILE_H by something unique in your project. In general, you can simply use the filename.
|
|
|
|
|
Why not only
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
at the top of the .h-file? Seems to work fine.
|
|
|
|
|
ensger wrote: at the top of the .h-file? Seems to work fine.
Yes, it will.
Way suggested by Cedric is one of the ways. And using pragma's make code dependent on particular compiler.
|
|
|
|
|
in headers, you shouldn't define variables. you should only declare extern variables, that means to the compiler that the variable has been defined somewhere in a c/cpp file ; it's the linker job to synthetize this.
|
|
|
|
|
Ayman Mashal wrote: and i want to know if its right to add #includes for the standard libraries in all files ?
Technically you can, but it's bad practice. Put them all in a single file common to all of your project. Since those files are not going to be changing, take advantage of precompiled headers by turning on precompiled headers for that single file.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I need to customize menu completely. Means including the border of menu. From CP, I found that for complete customization, we have to use windows hook. Is there any other method to avoid windows hook?
- NS -
|
|
|
|
|
NS17 wrote: From CP, I found that for complete customization, we have to use windows hook
NS17 wrote: Is there any other method to avoid windows hook?
Owner drawn menu.
Refer this[^] section on CP.
|
|
|
|
|
Thank you. yes i reffered this article. and found that it is working using windows hook. i need an alternate way to avoid hook.
- NS -
|
|
|
|
|
NS17 wrote: yes i reffered this article.
No, you haven't. You might have seen one of them.
I can see this article explaining owner drawn[^] menu.
|
|
|
|
|
Yes I did refer the same. But it uses the windows hook.
- NS -
|
|
|
|
|
NS17 wrote: But it uses the windows hook
No, it don't.
I'm not sure what link you are refering to.
But, I can see owner drawn menu BCMenu .
|
|
|
|