|
|
Hi people,
I'm trying to change the font used to draw in my view class, but there's something wrong. This is the code in my view's OnDraw handler:
CFont NewFont;
LOGFONT LogFont;
GetFont()->GetLogFont(&LogFont);
LogFont.lfWeight = FW_NORMAL;
NewFont.CreateFontIndirect(&LogFont);
I found this code in quite a few examples in forums, but the call to GetLogFont causes an assertion failure:
_AFXWIN_INLINE int CFont::GetLogFont(LOGFONT* pLogFont)
{ ASSERT(m_hObject != NULL);
return ::GetObject(m_hObject, sizeof(LOGFONT), pLogFont); }
I can't even figure out what the m_hObject is supposed to contain, let alone why it's NULL. Anyone have a clue?
Thanks a lot,
ren
|
|
|
|
|
The GetFont() call is returning NULL. This will normally only work if a call to SetFont() or WM_SETFONT message has already been done/sent to the window in question.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
How can I send an EMail from an MFC Project without DOC/VIEW Architecture and without MAPI messanging?
|
|
|
|
|
SMTP is an option. there is code here that will help.
-c
Cheap oil. It's worth it!
|
|
|
|
|
If i can't use CString in my non-mfc app then how do i use the AllocSysString?
Thanks
|
|
|
|
|
SysAllocString (and SysFreeString to free resources)
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Hi!
Is there a way to know if a mail program is present on a system and correctly installed. Because when I use the Windows MAPI functions, my program fails if there is no program set.
I'm programming in C-Windows.
Thks in advance!
Appstmd
|
|
|
|
|
You can check the following registry key to see if any profiles exist:
Win9X/ME:
Software\Microsoft\Windows Messaging Subsystem\Profiles
WinNT:
Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles
|
|
|
|
|
How can I write text and draw lines in a MS Word Application from an MFC Project without DOC/VIEW Architecture???
|
|
|
|
|
You might want to look at COM Automation. It's a lot of work to get your head round at first, but it'll do what you need.
A starting point would be in MSDN, under:
Platform SDK-->COM and ActiveX Object Servies-->Automation
HTH,
Pete
|
|
|
|
|
Are there any specific precautions to using A2W? I am using it in a small piece of code that I have written and I have noticed that at times it appears that I have memory problems.
Any specific things that I need to watch for?
|
|
|
|
|
Acutally sorry I had forgotten to use SysAllocString!
thanks
|
|
|
|
|
A2W allocates memory on the stack, so it may be a problem if you convert very large strings.
SysAllocString allocates memory for BSTR string, not w strings, although the code sees them as equivalent. The difference is that a BSTR has 4 bytes preceding the address of the string that tells the length (in bytes) of the string.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
As michel wrote, it allocates memory on the stack. But, if you use VC++ 7.0, you can use CA2W(), it allocates memory on the heap, if needed, but otherwise it works just like A2W().
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi,
I would like to create a script in C++ for introduce some datas into a executale.
For example : senddata /p test /r test1.
I create a little sample and after I execute my script, the prompt message is closed and I can't see the result.
My sample:
int main(int argc, char* argv[])
{
printf("Hello World!\n");
char *p;
int i;
int iErr;
for (i=1; i
|
|
|
|
|
This works fine (I just add the condition in the for loop)
int main(int argc, char* argv[])
{
printf("Hello World!\n");
char *p;
int i;
int iErr;
for (i=1; i < argc;i++)
{
p=argv[i];
if(*p=='/')
{
p++;
switch(*p)
{
case 't':
{
printf("Option :t is introduce\n");
iErr = 1;
}
break;
case 'T':
{
printf("Option :T is introduce\n");
iErr = 2;
}
break;
default :
printf("Nothing\n");
iErr = 0;
}
}
else
{
printf("Nothing\n");
iErr = 0;
}
}
return iErr;
}
~RaGE();
|
|
|
|
|
Yes, I know but I would like that the Prompt message is allways displayed and not destroyed.
Have you a solution for me ?
Best Regards
youssef
|
|
|
|
|
You can force a prompt at the end with
getchar(); ...
(BTW, the message is not destroy on my machine until you hit a key (even without the getchar())
How do you run your program ? In VC++ ? Or from the Explorer ? Or from Command Line ?
~RaGE();
|
|
|
|
|
What do i include? WHen i try to declare a CString it says undeclared identifier.
Thanks.
|
|
|
|
|
#include <afx.h>
~RaGE();
|
|
|
|
|
|
Unless you are using WTL you can't, because the MFC version of CString requires some MFC Internals. There is a WTL version but this requires you to use ATL and WTL.
John
|
|
|
|
|
VC NET
Use ATL::CString
#include <atlstr.h>
In VC 6, you can use WTL::CString if you download WTL, but the class in WTL 3.1 was not incredibly good.
Regards,
R.
|
|
|
|
|
Sorry, seems that the rest of my post got lost ... OK, Ramon gave you the right thing ...
~RaGE();
|
|
|
|