|
unless you know your tree will never exceed a certain number of nodes, you will most certainly have to use some kind of dynamic memory allocation (ex. malloc).
but...
in getResponse:
struct thing2 tmp2 = getThing2();
struct thing1 tmp1 = getThing1();
struct thing1 *p1 = &tmp1;
struct thing2 *p2 = &tmp2;
tmp1 and tmp2 are going to go out of scope when the function exits, so p1 and p2 are going to be pointing at garbage.
the malloc version works because those dynamically allocated structs still exist after the function exits.
|
|
|
|
|
So declare the struct instances globally.
|
|
|
|
|
Doing it by reference should work as well, but you're doing it wrong... think about what you did wrong in that instance (i.e. you're passing a pointer of an existing object to the call, it should not be loading an instance of a local variable).
|
|
|
|
|
Bacchus Beale wrote: since I would need to be sure it has all been freed.
So create the following functionality.
1. Measure the tree needed.
2. Alloc that size - one single alloc.
3. Create the structs, including pointers within that single allocated block.
When you are done with the tree then there is only one allocation to delete.
Your functions would look something like the following. Correct pointer arithematic provides pointer values.
int SizeOfThing2();
void SetupThing2(struct thing2* dst, char* word, struct thing1* s1);
|
|
|
|
|
Hi Folks,
I am trying to add a Video Player to a Form in
C++ Builder 5, Using the Object Inspector I change the Name field then I go to the FileName field to point to the AVI file I get a "Cannot Open AVI" error consistantly. I have serveral different AVI files which all work with the Windows Media player. BTW I am working on a Windows 7 machine. Any ideas please?
|
|
|
|
|
Just out of curiosity - can you post your code for openning the file?
|
|
|
|
|
I have a dialog based app I am writing. In this app I am going to have to present different information to the user and in some cases ask for some input in various orders depending on a given situation. I figured property pages would be a great solution since I could design a bunch of panels and then show them in whatever order I want, as needed.
The fundamental problem is that in a given area I just want to show just the panel I made. In one mode I get "tabs" like a tab control. In another mode (Wizard Mode), I get a bunch of buttons at the bottom.
If I could hide the tabs OR hide all the buttons in wizard mode, it would work. I also have a bitmap logo on top, and I thought if I could get the bitmap to draw itself after the property sheet, I could hide the tabs underneath it, that might work. I do not know how to make the property sheet object draw itself before the bitmap logo at the top.
So is there a way to do this or just render my panels with no extras at all inside my dialog box?
|
|
|
|
|
|
Thanks for that, Ill look into it. I was pursuing something similar on my own, giving up on Property Sheets / pages altogether. It was just overlaying modless dialog boxes inside the main one.
|
|
|
|
|
DeepT wrote: The fundamental problem is that in a given area I just want to show just the panel I made. In one mode I get "tabs" like a tab control. In another mode (Wizard Mode), I get a bunch of buttons at the bottom. So why not make both (i.e., one dialog that is a tabbed property sheet, and another dialog that is a wizard property sheet), and only show the one that is needed (based on some condition)?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
If you just make one property page, you get one tab shown at the top. I didn't want ANY tabs to be shown. If you use wizard mode, you get the buttons. I do not want any buttons. I hope I am being clear on what I wanted to do.
|
|
|
|
|
Is there a reasonable way ( in VC6.0 & MFC 4.0!) to update CPropertyPage using UpdateAllViews?
I can manage to pass the document pointer to the page but cannot find an easy way to pass the UpdateAllViews message to the page(s).
Perhaps iterating thru all of the pages ( using MFC), posting each update in similar MFC fashion ? How?
Thanks for your help.
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: Is there a reasonable way ( in VC6.0 & MFC 4.0!) to update CPropertyPage using UpdateAllViews?
Why would you want to? That's for documents and views. Why not use QuerySiblings() instead?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Because it does not exist it VC 6.0 MFC 4.0
|
|
|
|
|
Sure it does. Check line 289 of dlgprop.cpp and line 528 of afxdlgs.h .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Thanks David,
somehow my ancient MSDN could not help me find it.
And I just did not think the page itself would do it, but I guess that is why they call it "querrysiblings", duh!
So if I get to any page from the UpdateAllViews which starts the update, I should be able to figure it out. I guess I can pass the document pointer that way too, super.
It seems strange way to do page updates, bypassing the sheet and the frame, but if it works what a hey.
Thanks again for your persistence.
Vaclav
Addendum
It seems that there are some holes in my old MSDN docs and MFC and API functions for updating pages are not same.
It looks as API runs the update from the sheet and MFC from page. Either way, the PSM messages are hidden in MFC doc and the document pointer cannot be passed directly to the page using the QuerrySiblings.
-- modified 19-Jun-12 18:39pm.
|
|
|
|
|
If you need access to the document from some other place (e.g., property page), try:
AfxGetMainWnd()->GetActiveDocument();
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Thanks David,
I like this better than "dragging" the document pointer thru the property sheet which does not need it. KISS!
I am still not sure about MFC QuerySiblings - from page "up" the sheet and than "down" the pages.
|
|
|
|
|
Vaclav_Sal wrote: I am still not sure about MFC QuerySiblings - from page "up" the sheet and than "down" the pages. If you are wanting one page to be able to notify the other pages of a change, calling QuerySiblings() is the way to go. If some other route needs to take place (e.g., document notifying the sheet of a change), that may not be the best solution.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
David,
I have been going round and round tryig to figure out why I am udating only one page. Did not quite catch anything strange stepping thru the MFC code. Than I read the "fine print"
"...to each
// LOADED page (a page won't be loaded in memory until it is shown)..".
Make sense, why update something which is not active.
I assume that it means when I change the page (tab) I better make sure that the whole view update business better starts again. It should work.
This has been educational for me.
Thanks.
|
|
|
|
|
Consider an 8-bit compiler say Turbo C, in which we have an integer of size, say 2-words i.e. 16-bits or 2 bytes. You need to store three integer values which are supposed to be as:
Name | Range | Size Required
=====================================
Integer 1 | 0-3 | 2bits (00-11 in binary)
Integer 2 | 0-5 | 3bits (000-101 in binary)
Integer 3 | 0-7 | 3bits (000-111 in binary)
In total, we need only 8bits to store all of these three values. Which means that a single variable of integer data type has enough memory to accommodate these values.
The challenge is to store all of these three variables into a single instance of integer data type and retrieve it whenever required.
In other words, you need to develop a program which can - at the maximum - use only two instances of integer data type, first one for the purpose of scanning values from the standard input device say keyboard and the second one to store the data entered by user in the form of three integer variables as discussed above and print them by retrieving it from the second instance in which the data was stored.
Company Description Secpanel is a DIY security tool for cloud servers.
Please see www.secpanel.com Requirements We are trying to solve the security problem for millions of servers on the internet. We are looking for people who are crazy enough to think they can solve the toughest of problems. And do. If you love to code and are sick of the protocol/HR/politics of big organizations, you should talk to us.
Instead of a resume, please write a small piece of code for the following scenario:
Consider an 8-bit compiler say Turbo C, in which we have an integer of size, say 2-words i.e. 16-bits or 2 bytes. You need to store three integer values which are supposed to be as:
Name | Range | Size Required
=====================================
Integer 1 | 0-3 | 2bits (00-11 in binary)
Integer 2 | 0-5 | 3bits (000-101 in binary)
Integer 3 | 0-7 | 3bits (000-111 in binary)
In total, we need only 8bits to store all of these three values. Which means that a single variable of integer data type has enough memory to accommodate these values.
The challenge is to store all of these three variables into a single instance of integer data type and retrieve it whenever required.
In other words, you need to develop a program which can - at the maximum - use only two instances of integer data type, first one for the purpose of scanning values from the standard input device say keyboard and the second one to store the data entered by user in the form of three integer variables as discussed above and print them by retrieving it from the second instance in which the data was stored.
|
|
|
|
|
nobody here is going to do your work for you.
and if you can't do the work, you shouldn't get the job[^]
|
|
|
|
|
priceless!!
Watched code never compiles.
|
|
|
|
|
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
hi all, i'm in trouble by writing the header of a jpeg file. after i acquire the raw image and processing it by DCT, quantization and huffman coding, i would like to save it in the correct format. i can't found any libraries that help me to write proper header file, insert the 2 tables that i used (huffman and quantization), so i start writing every byte by myself... i start with the SOI marker, frame header and so on.... but when i try to open the jpg image with a viewer, it shows nothing... even in the properties do not shows any information, nor the image dimension etc, even if i insert those info like written in the official documentation... i try to scan the header with other program, but they show errors... so my question is "simple"... how i can write a proper jpeg header? thanks p.s i use VS 2010 and c++
|
|
|
|