|
Can you just tell me the way of using it
|
|
|
|
|
Add WM_CLOSE message handler for you CMainFrame class. This is the handler called, when you click on cross button.
Prasad
MS MVP - VC++
|
|
|
|
|
Thank you very much
It solved my problem
|
|
|
|
|
Hi All,
I want to generate different GUIDs in my ANSI C++ application. Can anyone help me to do this or can point to a library which i can use?
Regards,
Aamir
Aamir Zia
|
|
|
|
|
Use the CoCreateGuid() or UuidCreate() APIs. If you need to avoid Win32 APIs, the algorithm for generating them is in RFC 4122[^].
|
|
|
|
|
Is this ColorDialog(RGB(255, 0, 0)) a MFC member function
S.Yamini
|
|
|
|
|
yaminisridaran wrote: Is this ColorDialog(RGB(255, 0, 0)) a MFC member function
Probably, you wanted to say CColorDialog[^].
Prasad
MS MVP - VC++
|
|
|
|
|
I used the below coding
CColorDialog dlg(RGB(255, 0, 0), CC_FULLOPEN);
int retval = dlg.DoModal();
if(retval == IDOK)
// retrieve the chosen color
COLORREF color = dlg.GetColor();
but I want to display this color how can I implement it
S.Yamini
|
|
|
|
|
yaminisridaran wrote: but I want to display this color
where ? how ?
you want to pick a color to use it somewhere ?
|
|
|
|
|
Hi,
I have developed an installer for my MFC based application.
I create a new Environment variable at the time of installation.
But my MFC application is unable to access the new Environment variable unless I restart the computer.
Is there any way that I get the newly created Environment varialbe without restarting the computer?
Thanx.
|
|
|
|
|
After you make a new environemnt variable, you need to broadcast a WM_SETTINGCHANGE message.
|
|
|
|
|
Hello,
is there some event that can be registered for a new process that might start in the future?
So far I have a Thread that checks whether there is a new process running and then sleeps for some time.
I dislike using the sleep-function. I'd rather like to register some event for this.
Is there anything like that?
I hope I could make myself clear and I hope you have an answer?
Thank you for reading so far.
regards
-- modified at 19:47 Sunday 15th April, 2007
|
|
|
|
|
Look up "Interprocess Synchronization" and "Synchronization Functions" in MSDN. I've never done this across processes...only interthread, but a quick glance at it suggests it is basically the same.
The concepts you'll be interested in are alertable waits, the function WaitForSingleObjectEx, and probably CreateEvent and SetEvent.
However, this requires that the other process participate in the syncronization and I'm not sure if that is precisely what you were after or if you require the other process your waiting on not have any knowledge or code committed to this syncronization. If that is the case, this will not likely help you much but I thought it worthwhile to put it out there, just in case.
I hope it helps.
|
|
|
|
|
Thank you bob16972,
I'm going to have a look at the topics you suggested. Maybe it will fit my needs.
kind regards
|
|
|
|
|
Hey all,
My last [meaningful] programming experience was programming assembly on the 6502/6510 and the 6802 MPUs in the early eighties. I'm tending to relate the function of pointers in C++ to the role of the "Indexed Addressing Mode" in assembly (e.g. LDA $0400,X ), but there seems to be a significant layer of abstraction that I'm not grasping. I've never programmed in C or C++ or really any HLL since the 80's and I'm having tremendous difficulty with pointers.
I see a lot about how great and useful they are, but aside from the mundane examples, their real usefulness evades me. The examples likely containing *practical* examples are equally likely far beyond my C++ proficiency level. Given this relative impass, can someone explain in general terms what application might be aided by pointers? (Indeed, there must be some application in which pointers are absolutely necessary.)
Naturally, links to existing resources would be great as well.
I'm certain that relating pointers with indexed addressing is a significant fallacy, but right now it's all I have to work with.
Thanks,
fadibitz
If you see only one solution, then you don't understand the problem.
|
|
|
|
|
Here are a couple reasons to use pointers:
1) Dynamically allocating memory.
Once you dynamically create a type, you need a pointer to locate it and employ it. Also, dynamically a type or a collection of types, makes your applcation more scalable.
2) Passing large objects or collections by reference.
Passing a large object to a function by value means you have to copy the object and waste time and memory. If you pass it by reference via pointers, only the pointer gets copied.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
In addition, sorting is much faster by organizing the pointers rather than moving the data around.
Searching can be made much faster using pointers in a specific manner as well.
There are a number of reasons to use pointers over other data types, but only the developer (such as yourself) can determine if the pointers are truly necessary.
Phil
|
|
|
|
|
All of these responses make an icredible amount of sense. Thanks for the wide view.
It's looking like the way to procede is to take my "overview" of pointers and move on to other programming topics like structures, classes, and templates. My guess is that as I progress through these programming concepts, techniques and examples will call on ever more advanced usages of previously-learned things. Pointers included. Trying to understand them fully without benefit of prior experience or real understanding of c++ fundamentals is (or seems) destructive and self-defeating.
What say you all?
Robert Nicholas
---------------
If you see only one solution, then you don't understand the problem.
|
|
|
|
|
My first suggestion is for you to "play" or "Experiment" with pointers until you understand what you can and should not do.
Phil
|
|
|
|
|
Coming from assembly before C/C++ myself - pointers are the closest to a one-to-one relationship
with CPU addressing. It's the lowest level abstraction, just above "Indexed Addressing Mode" in
assembly. The benefit is performance and control. The drawback is when mistakes are made coding,
they are bad - the compiler can't save you Higher level languages hide these issues,
sacrificing a bit of performance for safety and ease of use (or hiding the concept of memory
addressing altogether).
My 2 cents.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Yes, power corrupts. When you mess up, it corrupts absolutely.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Confirmed!
Robert Nicholas
---------------
If you see only one solution, then you don't understand the problem.
|
|
|
|
|
You have received some good answers so I will keep this simple.
A pointer is the address to a block of memory, just as a street address is the address of the house and not the house itself. If you wish to have a separate function manipulate the contents of the memory block, then you need to pass the address to that function so that it knows where the memory block is located.
The C string manipulation functions are good examples of using pointers: see strcpy amongst others.
If you want to create your own liked list, instead of using the STL ‘list’ template, then pointers are essential: struct node { some data variables; struct node* pNextNode; };
Example (in generic C):
void clear_buffer(void* pBuffer, unsigned nSizeInBytes)
{
unsigned char* p = (unsigned char*)pBuffer;
unsigned i;
for( i = 0; i < nSizeInBytes; ++i )
p[i] = 0;
}
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi,
I use the function ShellExecute to start an application, say MyApp.exe. Does anyone know how to terminate the process of MyApp?
It seems ShellExecute can return a handle (the first parameter of ShellExecute). I tried to use TerminateProcess to end MyApp but I failed. It seems the handle is not the "real handle" of the process, right?
Thank you a lot for your help!
Jeffrey
|
|
|
|
|
I've never tried to terminate something spawned from ShellExecute so I can't help there but...
A quick search of my projects, I found one that uses CreateProcessWithLogonW and later if problems develop it resorts to using TerminateThread utilizing the handle in the processInformation structure that is filled in CreateProcessWithLogonW. CreateProcess has a similar parameter list and utilizes the processInformation as well so I would guess you should be able to use CreateProcess for the same purpose though I've never tried it.
Hope that helps.
|
|
|
|