|
Hello, I'm having a very difficult time changing parameters using code to a program that has a few labels. I was able to move their position, change their color, but unfortunately not their sizes. This project also uses ActiveX. I'm using VS 2008, and the only articles that give any insight are all for VS 6.
m_lblctrl1.SetWindowPos(&wndBottom,0,0,0,0,SWP_NOSIZE);
changes m_lblctrl1 position (x,y,cx,cy)
m_lblctrl1.SetForeColor(RGB(255,0,0));
changes m_lblctrl1 to red.
m_lblctrl1.SetFont(LPFONTDISP);
now this is where i've been hitting a very bad wall
this is the method i've been tackling.
CFont font;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = 12;
strcpy_s(lf.lfFaceName, "Arial");
VERIFY(font.CreateFontIndirect(&lf));
m_lblctrl1.SetFont(&lf);
the error i'm getting is "error C2664: 'CLabel::SetFont' : cannot convert parameter 1 from 'LOGFONT *' to 'LPFONTDISP' " I've done all the research i could do to properly troubleshoot this, but unfortunately i've hit the point where i need professional help. m_lblctrl1 is defined as a CLabel in case that helps. Also i used Do Data Exchange from the original label defined:
DDX_Control(pDX, IDC_LBLCTRL1, m_lblctrl1);
If anyone has experience with this LPFONTDISP and how to change the label size/font, i'd greatly appreciate help.
Thank you for any input, if there is any details i left out, I'd gladly add it.
-David
|
|
|
|
|
Dragondima wrote: m_lblctrl1.SetFont(&lf);
Why don't you use
m_lblctrl1.SetFont(&font);
?
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]
|
|
|
|
|
Hey, thanks for the reply!
I tried this earlier, and got the same "error C2664: 'CLabel::SetFont' : cannot convert parameter 1 from 'CFont *' to 'LPFONTDISP'"
|
|
|
|
|
OK. Now I'm aware your CLabel is an ActiveX control. You have to use OleCreateFontIndirect [^].
Sample code here.
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]
|
|
|
|
|
Thanks for the reply!
I'm having a hard time getting the exgrid.dll to work, their examples give me a lot of errors. This was more for VS 6 i'm using 2008. I don't know if this would make a difference, i downloaded the file, but haven't had much success. Other suggestions would be greatly appreciated!
|
|
|
|
|
Hi
I need to read and save a class instance pointer.
class A
{
}
A* pClassA = new A(); I want to read and save "pClassA" from and to a file. What kind of data type it is? How many bytes it will take?
I am using CFile to do file IO.
Best regards,
modified on Thursday, January 21, 2010 9:15 AM
|
|
|
|
|
Saving a pointer doesn't make any sense. A pointer is merely a memory address, how useful would that be ?
What you probably want to do instead is save the content of your object to the file. In that case, you will need to save each member variables separately.
I suggest you take a look at this article[^] (and the full series) to have a better understanding of serialization.
|
|
|
|
|
Usually, that make no sense: a pointer contains the address of an object, so what is the purpose of storing it? If you need to store the class instance (i.e. the object itself) then you should look at serialization (Serialization on Wikipedia, Serialization in MFC).
Ah, of course the size of the pointer pClass is
sizeof(pClass)
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]
|
|
|
|
|
Hi I all a newbie here. need help with this:
char *strtok( char *str1, const char *str2 );
char str[] = "now # is the time for all # good men to come to the # aid of their country";
char delims[] = "#";
char *result = NULL;
result = strtok( str, delims );
while( result != NULL )
{
printf( "result is \"%s\"\n", result );
result = strtok( NULL, delims );
}
for char str[] , how can i assign it to a variable b? so far i get this error:
readin.cpp:34: error: initializer fails to determine size of ‘str
Thanks alot.
|
|
|
|
|
xivShin wrote: char *strtok( char *str1, const char *str2 );
What's the purpose of the above line?
xivShin wrote: char str[] = "now # is the time for all # good men to come to the # aid of their country"
Is the compiler complaining of the above line? Strange! What compiler are you using?
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]
|
|
|
|
|
first address the issue pointed out by the esteemed CPallini
then, try either
char str[74] = "now # is the time for all # good men to come to the # aid of their country";
or
char * str = "now # is the time for all # good men to come to the # aid of their country";
|
|
|
|
|
if b is a pointer:
char *b = str;
or
if b is an array and you need to copy the whole null terminated string to it:
#define SIZE 200 // or any suitable value
char b[SIZE];
strcpy( b, str );
One suggestion: please use meaningful names as variable names instead of b
|
|
|
|
|
Raj Indian wrote: One suggestion: please use meaningful names as variable names instead of b
b is soooooooooo meaningful.
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]
|
|
|
|
|
You don't have a variable b in your program. Therefore it's hard to determine what the message means -- we don't know the type of b. So you need to offer more details.
|
|
|
|
|
xivShin wrote: for char str[] , how can i assign it to a variable b?
char* b = str;
But remember that b is merely a pointer to the same string. If you want a copy then you need to use strcpy() or some derivative.
MVP 2010 - are they mad?
|
|
|
|
|
Hello,
i need to show text underlined in CListCtrl when someone goes with the mouse over them, the text is always URL Adress,
and when the mouse is over a other cell it should be a just normal text!
My solution is not good, because the row is bigger then before and it dont restore the text to previos style when i move the mouse to other cell!
(I try with CDC, CFont, LOGFONT, CRect etc.!)
I hope that is understandable what i mean!?
Is there any way to do this!
(i think i see here a sample with this, but i cant find it!)
Thanx for any help!
Arrin
|
|
|
|
|
Try CListCtrl::SetExtendedStyle()
refer: http://msdn.microsoft.com/en-us/library/bb774732(VS.85).aspx
|
|
|
|
|
Hi,
I am trying to run a .bat file through command prompt using code via ShellExecute but not able to do so.
ShellExecute(NULL,_T("open"),_T("cmd.exe"),_T("b.bat iiso.img"),szDefaultDir,SW_SHOW);
I am getting command prompt but not able to execute command (bat file)?
|
|
|
|
|
I think you may need the "/C" option to get cmd to run the batch file thus:
ShellExecute(NULL,_T("open"),_T("cmd.exe"),_T("/C b.bat iiso.img"),szDefaultDir,SW_SHOW);
MVP 2010 - are they mad?
|
|
|
|
|
Thank you, How to do in hidden mode?
|
|
|
|
|
I think its a bit messy doing that this way .. but you can START a seperate process as hidden from within the CMD session though .. so I think the command becomes
/C START /B b.bat iiso.img
note the 'START /B'. If you go to a cmd session and do a 'help start' you'll see what I mean.
The different way is to have an exe that does a createprocess and sets hidden etc on the window. There a utility here (below) and doubtless others around that may help
http://www.ntwind.com/software/utilities/hstart.html[^]
hth
'g'
|
|
|
|
|
john5632 wrote: How to do in hidden mode?
I presume by using the SW_HIDE flag as the lastparameter.
MVP 2010 - are they mad?
|
|
|
|
|
I use the CBalloonMsg class from codeproject to display balloons, but I can't find a way to make it appear above its tracking point. The class uses the TTM_TRACKPOSITION message to position the balloon, but this message only takes one argument, which is the tracking point. How can I specify the rectangle of the body of the balloon?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I have a problem with my mfc application.
In the application I open an usb output device, prepare a data block for playback
and then send the data with waveOutWrite. Afterwards I unprepare the data block and
then I close the usb device.
Under Windows XP my program works properly but under Windows 7 it fails.
When I watch the usb interface with an analyzer I see that under WinXP the prepared data
block is sent but under Win7 there are only sent zero bytes and not the data block.
Why does my application not work under Win7?
I am thankful for your answers.
|
|
|
|
|
Does waveOutWrite fails (did you check the return value)?
Could you please post the relevant code?
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]
|
|
|
|