|
Probably, you are calling SetFont function on uninitialized CWnd object.
Prasad
MS MVP - VC++
|
|
|
|
|
I don't think that's the real problem. In this particular project, I've added a new dialog by copying and pasting the relevant parts of the dialog from the .RC and resource.h files. I've also added the .CPP and .H files for this dialog to the workspace. Plus the files I copied into the different project worked just fine in the old project from where they were copied. To me, this error just doesn't make sense. Is there anything else that could be the problem due to my copying and pasting from one project to another?
Thanks again.
John P.
|
|
|
|
|
jparken wrote: I don't think that's the real problem.
Actually, that IS the problem. Whatever control you are trying to set the font for has a NULL window handle. Check the call stack when that assertion fires to see where your code is in error.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
David --- I'm having a problem with the underlying logic then. If these same files do not have this problem in the other project (which is identical except for the addition of one new dialog), then why would this error appear in the one with the new dialog, which has not even been called by the system when it first loads up? Or does that not matter in a case like this? I'm going on the assumption that the problem is in the very first dialog that is being called at statrup of this .exe --- poor assumption on my part?
Thanks
John P.
|
|
|
|
|
One possible reason for this would be that when you copy files/resources from one project to another, the controls on the copied dialog may have the same resource id as other controls that you already have.
Open your resource.h file and look for duplicate numbers for the resource IDs. If there are duplicates, renumber them to eliminate the duplicates, the completely rebuild your project.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
jparken wrote: Is there a tutorial that could help?
When you're dealing with code that you're not familiar with, usually the fastest way to track down this type of problem is to run the app under the VS debugger, and then look at the stack to see how it got there. The code that you posted is somewhere within the MFC libraries. So what you need to do is to find out how you got there.
The good news is that dialog-based apps are the simplest kind of MFC app. Do you see the dialog at all before the ASSERT error? If not, then there is a good chance that the dialog template in the RC file is incorrect or missing; or the IDD resource id in resource.h doesn't match what's in the RC file, or in the dialog's .h header file. Just make sure everything matches up - for dialog apps, it's pretty straightforward, and will fix this kind of problem 90% of the time.
After making any changes, be sure to recompile everything, to make sure it's all in sync.
Best wishes,
Hans
|
|
|
|
|
Hallo Community,
it would be very nice if anyone could point me possible reasons for the misbehaviour of my MFC-MDI-App.
We want to start the app via DDE '[open("%1")]', which works fine with the app already
running, but fails, if the DDE client has to start the app.
As I've found in an msdn-blog, the calling process waits for the app finishing its initialization by calling 'WaitForInputIdle'.
I've reproduced this calling procedure in an old DDE-Client sample from MSDN (using DDEML, hiding the interesting part), and get the same behaviour: After successfully waiting (return of WaitForInputIdle is 0), the WM_DDE_INITIATE message gets still not send to my apps main window.
If I insert a short time of Sleep between the Wait and the connection attempt in the client, it works fine again.
The question is, what is my app doing/why is the main window not available as target for the DDE-client after WaitForInputIdle() has returned ?
The error message from explorer is 'File xxx not found', which comes before InitInstance is processed.
When the app is started via double-click in explorer using the debugger by defining the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MYAPP.EXE\debugger=...' everything is working fine again.
Any hints highly appreciated !
Best regards
Reinhard
|
|
|
|
|
Is there any way to determine why windows believes an app requires elevated permissions. There's plenty of info on how to elevate and partial lists on what triggers elevation (manifests, install.exe, setup.exe etc.) but how do I find the reason for my app. I've tried the Standard User Analyzer but that doesn't seem to provide what I'm looking for. The only suspicious entries are to do with registry access which I've ruled out and a deliberate administrator check which, according to the call stack, happens after the program has dissappeared into DefWindowProc(). It would be nice if there was another utility or API available.
|
|
|
|
|
Steve Thresher wrote: The only suspicious entries are to do with registry access which I've ruled out
Vista seems to grant setup apps an elevated priority, so if you access a registry setting from within the setup, then after setup it will be available at normal priority. This is sometimes the reason why a registry operation will seem to fail for no apparent reason. One solution I have seen is to execute a small app during setup, which will establish the base registry keys and their permissions. I can't tell from your description whether this might help.
Best wishes,
Hans
|
|
|
|
|
Hi All ,
I have some dialog and on it i have CListCtrl.
I need to draw something on this Controller and i don't know how to do it.
I don't know if i can do it by overloading the method Paint or on event OnDraw -
I don't want to do it by call heritage from CListCtrl - and I'm sure there is other way to do it.
Thanks for any help.
|
|
|
|
|
What you mean by "draw something" ?
Whatever you draw will probably be overdrawn by the items in the list.
or are you wanting to custom draw the items ?
|
|
|
|
|
Ok, Sorry that i did not explain.
The "Draw" can be lines on the text , or some circle around the text or something like that.
How/ can i do it ?
|
|
|
|
|
|
So this will draw the text ( or the background of the text ).
I could not do catch the DCD to draw on it in this method.
Is there some other solution ?
|
|
|
|
|
|
Hello,
Could you please tell how to implement ActiveX BEGIN_EVENTSINK_MAP in a CView derived class?
I know that it is done automatically from the event handler wizard when the ActiveX is added into a dialog box but I have no clue with views.
Should I do it manually?
many thanks for your help.
|
|
|
|
|
Hi all:
I have been writing a FIFO structure, but ran into a problem, it seems to me that my FIFO structure is not properly built at all.
Below is my code: (it complies with no errors or warning.)
struct _wordTable *first = NULL, *end = NULL, *current = NULL;
int number_of_word = 0; /*A global variable to indicate how many words 'addWord' function
has been added to the table.*/
void addWord(char *wordPtr)
{
/*wordSize is declared to store the length of a word.*/
int wordSize = 0, loop = 0;
struct _wordTable *working_ptr = NULL;
/*Allocate memory for new pointers.*/
working_ptr = malloc(sizeof(struct _wordTable));
if (working_ptr == NULL){
fprintf(stderr, "Out of memory.\n");
free(working_ptr);
return;
}
working_ptr->word = malloc(1);
if (working_ptr->word == NULL){
fprintf(stderr, "Out of memory.\n");
free(working_ptr->word);
free(working_ptr);
return;
}
/*Measure the length of the input string.*/
wordSize = strlen(wordPtr);
/*Trying to find a match by linearly going through the list, if one is found,
return to the caller funciton after increasing the count by 1.*/
/*If the word is already on the FIFO structure, increases the word count by 1 and return to main().*/
if (number_of_word > 0)
for (working_ptr = first; working_ptr != end; working_ptr = working_ptr->next) {
if (strcmp(wordPtr, working_ptr->word) == 0) {
/*Here is where my program will crush.*/
working_ptr->count++;
return;
}
}
}
/*If the word is a new one, add it to the FIFO structure.*/
working_ptr->count = 1; /*Add one to the count after its initialzation.*/
realloc(working_ptr->word, wordSize);
strncpy(working_ptr->word, wordPtr, wordSize);
working_ptr->word[wordSize] = '\0';
number_of_word++; /*A new word.*/
/*Now link them together in a FIFO fashion.*/
if (first == NULL) {
first = working_ptr;
current = first;
}
current->next = working_ptr;
working_ptr->next = end;
}
Any help is appreciated.
|
|
|
|
|
C_Zealot wrote: /*Here is where my program will crush.*/
working_ptr->count++;
Which doesn't mean a whole lot without any supporting data? What does "crash" mean? What is the value of working_ptr->count at the time of the crassh. What does the call stack look like?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I'm seeing this, but I could be wrong...
struct _wordTable *first = NULL...
...
for (working_ptr = first;...
if (strcmp(wordPtr, working_ptr->word) == 0) {
That should crash because "first" is NULL, right?
Mark
Indentation is our friend!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
what's the problem with peoples on this forum today ?
can't you ask a question properly ?
i mean, format your code samples when you post some (using the <pre></pre> tags around it), and by giving better precisions than what you do. saying "there's a problem in my code" is not a question in my opinion, and nobody here is paid to fix one's code. you should first use your brains, and your debugger, spot the code piece that's the origin of your problem, and ask a specific question.
|
|
|
|
|
Give him some points... I thought he posted really good compared to other people:
- use of English language (+1 point)
- not writing "urgent" and "help mii" (+1 point)
- subject was not completely (!) off track (+1 point)
- able to miss a managed code forum (+1 point)
- generally friendly without cluttering text with roses and "sirs" (+1 point)
On the other side...
- code is C not C++ (-1 point)
- lazy in debugging own code (-1 point)
- not used to Code Project's formating (0 points)
--------------------------------
Overall 3 points = OKAY
|
|
|
|
|
i agree that he's not aggressive, and that's particularly appreciated. but open your eyes. should newbies pull the quality of this forum down, or shouldn't everybody here enforce hiwself to produce good quality question ?
moreover, when you say "not used to Code Project's formating (0 points)", i strongly don't agree. the forum provides a tag to format code samples. not using them not only lowers the readability of the post, but violates the codeproject stylesheet... the only reason for a pre tag not to be used is when the "Ignore HTML tags in this message" checkbox is checked.
so, i maintain the points given in my post
|
|
|
|
|
And doesn't anybody INDENT code anymore?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
indent ? crap, what the hell for ?!
|
|
|
|
|
toxcct wrote: what the hell for ?!
For me?
My head hurts trying to decipher matching curly brackets
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|