|
An extra tip would be renumbering a control after the complete dialog is set.
If you want to later change the tab order in the dialog editor press CTRL+D to show the tab numbers then hold the CTRL key down and clik on the item before you want to begin renumbering. Then release the CTRL key and the next item you click on will start with the number after the item you just clicked. So if you have 55 items and you need to renumber after the 30th one no need to start over. Just press CTRL click on the 30th release the CTRL and away you go.
|
|
|
|
|
Hi,
I want to be able to toggle between bitmaps each time the button (in a toolbar) is being clicked. How should I do it?
thanks,
yaron.
|
|
|
|
|
check thiz ......
http://www.codeproject.com/bitmap/bmpscroll.asp[^]'
u should find usful information in that....just got to modify that a little bit.....
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
Currently, I have a COM event which I've created a sink for and all of that jazz. It receives events at the Invoke method of course. Then i use dispIdMember to figure out which event was called. The only problem is that the event is fired from a different thread as the rest of my program, which poses a huge problem. Is there a way that I can call a function on threadA from threadB?
|
|
|
|
|
Hello, all.
I have some comments about linked lists & arrays and locality of reference.
Adding a node to a list a traditional method:
allocate each node using the new operator, then hook it into the list using "prev" and
"next" pointers.
This is fine, except that if you traverse the list a lot, accessing each node could
caused a missed cache hit or page fault, degrading application performance.
However, using an array-based structure to hold each data element offers much better locality of reference (all the nodes and data in one big allocation).
The drawback here is that it is harder to grow the array (reallocate to the new size,
then copy all the stuff over).
If you are not sure of how many nodes the list will contain, or if the data is some
complex structure, you may want to use a traditional method.
If you know exactly what the maximum capacity will be or if the data structure is
an fairly simple, and you traverse the list a lot, it may be worthwhile to store the
nodes in an array.
What it really concludes to, is it depends on what you are trying to do.
What do you all think?
|
|
|
|
|
When using a linked list, there is also the strategy of allocating chunks of memory that are multiples of your node size. For example, if you have a list of int (so your node size is 8, 4 for the int and 4 for the 'next' pointer), you could allocate memory in blocks of 8*N, where N is some "good" number you arrive at through perf measuring tools. Then when you add a node, you take that block and use the next available 8 bytes for the node. If you've used up a whole block, allocate another block and start using that.
MFC does this with its collections, the class that handles the chunks of memory is called CPlex (it's not documented, so you'll need to read the source).
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Thx, Mike! Found CPlex, indeed, in the MFC source.
Allocating blocks is not a bad idea, locality of reference is still relatively good, and you don' have to copy previous elements! That's not a bad idea; sort of the best of both worlds!
|
|
|
|
|
VC++ relationship between low-level objkects and GUI interfaces Question.-
Suppose I have base class A. And subclasses A1, A2, and A3.
class A {...}; // abstract class
class A1 : public A {...}
class A2 : public A {...}
class A3 : public A {...}
I want to allow a user edit A1, A2, or A3 properties through a Dialog Box. Though I have A1Dlg, A2Dlg, A3Dlg:
class A1Dlg : public CDialog {...}
class A2Dlg : public CDialog {...}
class A3Dlg : public CDialog {...}
Then, in my program, I have a list of A object pointers (where I actually have A1, A2 or A3 objects).
// this lines are to explain what I mean, not real code.
// Objects are not instantiated this way, how they are
// created depends on several factors.
A* m_list[n];
m_list[0] = new A1();
m_list[1] = new A3();
m_list[2] = new A2();
...
Question: because my A classes are very "low-level" they don't even know there exists a GUI, or a CDialog class. How can I show the correct Dialog using m_list?
I don't want to do A::displayDialog() because my A classes are very lo-level, they don't know a GUI exists, and they also run on Linux, and win cmd line. Besides that, I want objects to know as less as possible of the rest of the world (don't know if this is conceptually correct in com`puter design). This discards the chance to do:
m_list[x]->displayDialog()
Ugly solution: my solution (very, very ugly) was to declare a methods getType() this way:
enum { a1, a2, a3 } types_t;
types_t getType() = 0; // A class declaration
types_t A1::getType() { return a1; } // A1 implementation
types_t A2::getType() { return a2; } // A1 implementation
types_t A3::getType() { return a3; } // A1 implementation
And I have a "controller" that display the correct dialog box using a switch:
switch (m_list[n]->getType) {
case a1:
// display A1Dlg;
break;
case a2:
// display A2Dlg;
break;
case a3:
// display A3Dlg;
break;
}
Yeah! It is not nice. But This way I have very well separated the data objects (A1, A2, A3) and the view objects (A1Dlg...).
Yes, I've read MVC, but I can't figure it out how to do this "match" in an elegant way.
Can anybodey help? Thanks a lot!
|
|
|
|
|
You have to enable some from of RTTI (Run Time Type Information). The way you did it is ok, but you are probably better off using the built in way. Look up RTTI, /GR, and dynamic_cast in MSDN.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi Everybody,
I have problem with global functions in VC++.Net, is simply
add a global function in my project like:
UINT MyThreadProc(LPVOID pParam)
{
...
return 0;
}
and then when i want to call it for example when pressing abutton : AfxBeginThread(MyThreadProc,0) , i get an error :
c:...: error C2065: 'MyThreadProc' : undeclared identifier
can anyone help ?
Regards
Giorgi Moniava
|
|
|
|
|
When the compiler compiles a cpp file it starts at the top and works it's way down. If it finds an identifier (variable or function) that was not declared in a line above the current line it will generate this error. What you have to do is either insert a forward declaration of your function at the top of your cpp file (header files are a good way to do this), or move your function to a point in the file before the line that caused the error.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I want to restart the process. At first i created the process using createprocess() and then suspend it using suspendthread() and then i saved its state and information about it e.g. baseadress, context, state e.t.c in a binary file, after that i terminate it. Now i want to recreate it using its suspended state information. Pliz help me about this because i tried to use the functions below but the process doesnt restart again or atleast how to recreate a process using information from a previous saved information.
<br />
case 5:
<br />
SuspendThread(pi.hThread);
printf("\nThe thread of ID: %d",pi.dwProcessId);<br />
printf(" has been suspended!\n");<br />
GetLastError();<br />
<br />
GetThreadContext(<br />
hProcess,
lpContext
);<br />
GetLastError();<br />
<br />
regnum = 0;<br />
base = 0;<br />
fp = fopen("checkpoint.bin","w");<br />
if( fp )<br />
<br />
while (base < sinfo.lpMaximumApplicationAddress) <br />
<br />
{<br />
VirtualQueryEx(hProcess, base, &mbi, sizeof(mbi));<br />
<br />
if (mbi.State == MEM_COMMIT)<br />
state = "Used";<br />
else if (mbi.State == MEM_FREE)<br />
state = "Free";<br />
else if (mbi.State == MEM_RESERVE)<br />
state = "Reserved";<br />
else<br />
state = "Unknown";<br />
<br />
<br />
printf("\nREGION #%d\nState:%s\nBase Address:%p\nAllocation Base:%p\nAccess Protection: %08x\nRegion \<br />
Size: %08x\nProtection: %08x\nType: %08x\n", regnum, state, mbi.BaseAddress, mbi.AllocationBase, \<br />
mbi.AllocationProtect, mbi.RegionSize, mbi.Protect, mbi.Type);<br />
<br />
base = (LPVOID)((unsigned long)mbi.BaseAddress + (unsigned long)mbi.RegionSize);<br />
<br />
regnum++;<br />
<br />
<br />
fprintf(fp,"\nREGION #%d\nState:%s\nBase Address:%p\nAllocation Base:%p\nAccess Protection: %08x\nRegion \<br />
Size: %08x\nProtection: %08x\nType: %08x\n", regnum, state, mbi.BaseAddress, \<br />
mbi.AllocationBase, mbi.AllocationProtect, mbi.RegionSize, mbi.Protect, mbi.Type); <br />
<br />
}
<br />
Sleep(3600);<br />
<br />
TerminateProcess(pi.hProcess, 0);<br />
<br />
break;<br />
<br />
case 6:
lpBaseAddress = 0;<br />
hProcess = mbi.BaseAddress;<br />
SetThreadContext( <br />
hThread, <br />
lpContext <br />
);<br />
OpenThreadToken(<br />
ThreadHandle,
DesiredAccess,
OpenAsSelf,
TokenHandle
);<br />
<br />
WriteProcessMemory(<br />
hProcess,
lpBaseAddress,
lpBuffer,
nSize,
lpNumberOfBytesWritten
);<br />
<br />
ResumeThread(hThread);
GetLastError();<br />
<br />
break;<br />
oam
|
|
|
|
|
You can't do what you are attempting. Process management is up to the operating system. Does the comment "restarting the process in the other machine " mean that you are attempting to move processes from one machine to another? That absolutely won't work either.
You need to design your application so that it can save its state to a file when it exits, and restore its state from a file when it starts up.
Software Zen: delete this;
|
|
|
|
|
When it starts up? Do you mean when i re-run it again.
My application automatically save the state of a process when i suspend it.
But now i want to use this state to restart/recreate this process again, e.g. like if i can send this information to another computer.
It was done before but this was in unix.
Check this:
Restoring[^]
oam
|
|
|
|
|
mpapeo wrote:
When it starts up? Do you mean when i re-run it again.
Yes.
mpapeo wrote:
My application automatically save the state of a process when i suspend it.
This won't work under Windows. There are too many external factors involved that you can't control.
mpapeo wrote:
It was done before but this was in unix.
I thought that might be the case.
mpapeo wrote:
Check this:
Restoring[^]
I skimmed through the article. They are describing the approach I recommended. The application saves its state in a file, and then can reload that file when it runs again. Saving the process memory space and restoring it won't work (especially moving it from one machine to another) because the contents of the memory space includes items that you can't control.
Software Zen: delete this;
|
|
|
|
|
Gary R. Wheeler wrote:
I skimmed through the article. They are describing the approach I recommended. The application saves its state in a file, and then can reload that file when it runs again. Saving the process memory space and restoring it won't work (especially moving it from one machine to another) because the contents of the memory space includes items that you can't control.
so do you mean it can be difficult in windows to implement this
Gary R. Wheeler wrote:
mpapeo wrote:
When it starts up? Do you mean when i re-run it again.
Yes.
Well if that is the case then it will be part of what i want. Because the process i am creating prints numbers on the screen. But i suspend it and save its state and then when i re-run it it then continues to print numbers from where it left i knew i will be moving to somewhere in my research.
You can give you email so that i sed you the code
oam
|
|
|
|
|
Hi all,
I got a AES impelmentation code in VC++ and have some doubts, which I cannot sort out.
Will you plssssssssss let me know if u are familiar with both the AES algorithm and VC++.
So that I can forward my doubts along with the programme.
Thx...
vendy2k4
|
|
|
|
|
My main question is, I need to be able to get the filesize of a file greater than 4 gb. I use Visual C++ 6.0, and I am most comfortable with fstream. The fstream pointers are only 32 bit however. Is there another function I can use to get the filesize?
Two secondary questions are, one problem I have is sometimes the autocomplete/member listing stops working. I have to save everything, close, and reopen VC++ to get them to work again. Is there another way to fix it? And sometimes during compiling it will just stop before linking. I'll press the stop build button and it won't stop, I have to save everything and end the process via Task Manager. Is there a better way to fix that?
Thanks in advance for any help.
|
|
|
|
|
Master Shake 144 wrote:
Is there another function I can use to get the filesize?
I know of two: GetFileSizeEx() and CFile::SeekToEnd() (requires opening the file).
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
GetFileSizeEx only works on W2K+.
CFile::SeekToEnd() returns a 32bit value in MFC 6, a 64 bit value in MFC 7
_lseeki64 works on 9x and MFC6
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
|
|
int main(int argc, char* argv[])
{
switch(argc)
{
case 1:
break;
case 2:
if(argv[1] == "-help")
{
cout << "Help" << endl;
}
break;
default:
break;
}
return 0;
}
If the program in this case is named "prog.exe", when I type "prog.exe -help" into the command line, my understanding is that "Help" should be printed into the command line window. Any ideas as to why it isn't working?
Also, if there is a better way to check to see which program parameters have been passed in than the way I am trying to do so, please let me know. I am open to suggestions.
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|
One solution is strcmp().
Kuphryn
|
|
|
|
|
Thanks for the help!
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|