|
Hi all;
I have followed the instructions in MSDN for creating a bitmap button on a dialog box:
that is, I have drawn my bitmaps and named them accordingly with suffixes "U", "D", "F" and "X".
Then I have drawn my button on the dialog box, checking "Owner draw" in properties and with caption the name of the bitmaps without the above suffixes.
I have named a variable of type CBitmapButton in the dialog class and called the AutoLoad in 'OnInitDialog()' function as follows:
VERIFY(okBtn.AutoLoad(IDOK, this));
And I get an "ASSERT" error at this line:
ASSERT(FromHandlePermanent(hWndNew) == NULL);
What's the problem and what can I do?
Can somebody please help me??
_Lostris.
|
|
|
|
|
CBitmapButton can be cantankerous. You either need to call AutoLoad() before calling OnInitDialog() , or call LoadBitmaps() after calling OnInitDialog() .
Have you tried Joe's button class?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I've got a situation where we are running two redundant data servers where one should take over when the other fails. Our problem is in keeping the two servers synchronized when there may a thousand updates per second, and the order in which the updates arrive is very important and messages arriving in different orders to the two servers will cause problems. It is not a standard database (it's proprietary format), and everything is stored in memory. Basically, any data loss during the failover should be kept to a minimum. Some is allowed, but there are no guidelines on this. Less is better of course...
Obviously this problem has been overcome for large databases, but my search of google for algorithms has so far been fruitless. Does anyone have any information on synchronization algorithms that may help?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Friends i want to display a 48*48 icon on the dialog window. For this purpose i first created the desired icon, Then i placed a picture control on dialog and given it, the path to my icon. But the problem is that, the picture control shrinks my icon and unable to display it in the original size of 48*48. Can anyone tell me abt the problem here?
Imtiaz
|
|
|
|
|
specify to the ressource editor that the icon is 48x48 instead of 32x32.
do this in the combobox up to the area you edit your icon in VC++. if this doesn't apear in the choices, click the button next to it.
TOXCCT >>> GEII power
|
|
|
|
|
I have taken a CView class and ripped it apart head to toe keeping only those few things I need for dynamic creation pretty much.
Why would IMPLEMENT_DYNCREATE cause a memmory leak???
The debugger is indicating a leak and points to this line
#ifndef CREATE_STATIC
IMPLEMENT_DYNCREATE(CMyOwnViewCls, CWnd)
#endif
What a bummer
Any ideas???
How do I print my voice mail?
|
|
|
|
|
Did you close your app prematurely?
This macro defines the function that creates the window dynamically - something like return new CMyOwnViewCls . If you don't allow the app to exit normally, the window won't be deleted and the debugger will complain that this line allocated memory that wasn't freed.
Remember that everything in the macro expands to a single line, so everything in the macro is on the same line.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Got it!!! Thanks for the help
EDIT: Weird, I just inserted a AfxMessageBox() inside OnCreate and it isn't called, so i guess my object has no connection with CView anymore and it's something else in the framework causing the TRACE to display
nope closed it normally...
For some reason, even though I stripped out all referecne to CView and replaced with CWnd....I still get an TRACE warning saying View created without a CDocument...which is weird, cua like I said my new class is small so i'm positive i'm not missing anything...and yet this TRACE is found inside CView viewcore.cpp line 99 and my class n longer derives from CView so I have no idea why CView::OnCreate is getting called...
How do I print my voice mail?
|
|
|
|
|
Hockey wrote:
How do I print my voice mail?
no you dont print a voice mail, you rewind and replay the voice mail.;P
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Most if not all MFC classes call delete this; in the WM_NCDESTROY message handler. So if you stripped that out the actual deletion of the object will probably no longer be done. Check the MFC source for PostNCDestroy() function.
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
I finally figured out what was causing the leak and that was it!!! It was so small I just kinda ignored it or didn't see it...
How do I print my voice mail?
|
|
|
|
|
Can anyone help me explaining what the below macro is supposed to do.
#define OFF(type, field) ((LONG)(LONG_PTR)&(((type *)0)->field))
d2hes
|
|
|
|
|
It gives the offset of a structure member from the beginning of the structure, in bytes.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks, but how does it do that?
|
|
|
|
|
#define OFF(type, field) ((LONG)(LONG_PTR)&(((type *)0)->field)) Take the following structure:
struct ThisStruct
{
char field1;
short field2;
int field3;
int field4;
}; If we call the macro as such: OFF(ThisStruct, field3)
Firstly, the macro creates a pointer to a ThisStruct structure at address 0: ((ThisStruct *)0)
Next, it refers to a particular field inside that structure: ((ThisStruct *)0)->field3
Next, it takes the address of that field: &(((ThisStruct *)0)->field3)
Since field3 is 3 bytes from the beginning of the structure, and the structure is at address 0, the pointer will hold the value 3.
Lastly, the macro converts the pointer to a LONG_PTR and finally to a LONG , to give an integer result - the offset of the field from the beginning of the structure.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
How can I change it???
I have looked into MFC and found ASSERTMSG, but this macro isn't defined when I build, and if I include it's header in which it is defined bh.h??? I get a million error messages
Any ideas?
Thanks
How do I print my voice mail?
|
|
|
|
|
I am trying to add some error handling to my project and I want to exit if either the configuration file from the command line doesn't exist or the configuration file has parsing errors. I have tried the code below using Visual Studio 2003 (MFC Dialog based application). The application does not exit. What is the correct way to force a shutdown of my MFC Dialog based application?
<code>
if( InitDOM( XMLFileName ))
{
if( !ParseDOM() )
{
CString msg;
msg.Format("Invalid node fetched.\n%s\n", (LPCSTR)pXMLDom->parseError->Getreason());
AfxMessageBox( msg );
PostQuitMessage(0);
}
else
{
ProcessPanels();
}
}
else
{
AfxMessageBox( " config file did not exist" );
PostQuitMessage(0);
}
</code>
|
|
|
|
|
Try EndDialog()
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I tryed this and it does not exit cleanly. I will look into it some more tomorrow as it is quite late at the moment.
|
|
|
|
|
smesser wrote:
I tryed this and it does not exit cleanly.
How so? This is how modal dialogs end. Modeless dialogs use a different approach.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I have not had a chance to look into it but I have a cleanup function and there are some calls to Killtimer that are crashing. What happens when you call Killtimer on a timer that was never set to begin with?
|
|
|
|
|
smesser wrote:
What happens when you call Killtimer on a timer that was never set to begin with?
Then KillTimer() should not be called. Use the return value of SetTimer() to know if the timer exists or not.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
I will have need to do this in a modeless dialog as well. What is the technique for that?
|
|
|
|
|
Modeless dialogs do not use DoModal() or EndDialog() . See MSDN for examples.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|