|
Use GetDC() to get the DC of the dialog and use that to draw on the dialog.
TextOut to output the text.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
where i use getdc() in oninitdialog on on paint
plz tell me an example for this
Ashish Dogra
MCA
Noida
-- modified at 9:17 Tuesday 27th June, 2006
|
|
|
|
|
You should use the function GetDC() whenever you want to draw something and ReleaseDC() ASAP.It's not suggested to hold on to a device context for long.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I USE IT IN ONPAINT WHAT I WANT TO ANIMATE THE TEXT ON STATIC OR EDIT CONTROL THEN HOW
WHERE I USE THAT ID BECAUSE GETDC () HAS NO PARAMETER
Ashish Dogra
MCA
Noida
|
|
|
|
|
No need to shout.
GetDC() returns a device context ( a CDC object ), which has plenty of member functions you can use to draw text or anthing. Search for CDC in the MSDN toget some infos about hte possibilities you have.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
PLZ SOLVE MY PROBLEM AS I CAN NOT SOLVE ITP LZ..............
....................................
plz tell me with some example as i am not so intelligent plz yar
and i am not shouting sorry for that.
i am new to vc++
as i do it myself and with the help of u people plz tell me clearly
Ashish Dogra
MCA
Noida
-- modified at 10:02 Tuesday 27th June, 2006
|
|
|
|
|
Create the DC where you need to draw.
You can use ::GetDC(HWND) if you have the handle to a window.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
ashish dogra wrote: plz tell me how can i made animated a text...dialog box
This should give you a general idea.
For an animated picture, can you use an animated GIF file?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
In my project, if I want to stop a work thread without waiting for it, how can I terminate it safely and compulsively as windows task management does?
|
|
|
|
|
There are some ways to stop a thread .
1) AfxEndThread()
2) TerminateThread()
3) _endthreadex()
IT's not safe to terminate a thread using the above functions.
You should check for a condition to be true. Whenever that condition turns true and the thread is still running, use return to exit safely from the thread function.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
zouchao1112 wrote: stop a work thread without waiting for it
Bad design. Why would you want to do this ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
zouchao1112 wrote: if I want to stop a work thread without waiting for it, how can I terminate it safely...
You can't. While TerminateThread() does indeed terminate a thread, it does so immediately and the thread has no chance to execute any user-mode code and its initial stack is not deallocated. DLLs attached to the thread are not notified that the thread is terminating. TerminateThread() is a dangerous function that should only be used in the most extreme cases. You should call TerminateThread() only if you know exactly what the target thread is doing, and you control all of the code that the target thread could possibly be running at the time of the termination.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
The general method is for the thread to periodically check a value and terminate if it matches some criteria. The simplest method is to check a bool and cleanup/exit if it goes to false. The preferred method is to use a manual set event handle and check it with a timeout of zero; if it goes signaled, I then can cleanup/exit. (The big advantage of the latter is that threads are often in a waiting state. With an event handle, you can do a WaitForMultipleObjects .)
(You would then set the "closing" event, and wait for say 5 seconds on the thread handle. If it doesn't close, log an event and call TerminateThread().)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
save the handle to the thread when you create it:
hthread = CreateThread ( 0, 0, MyThread, this, 0, 0 );
then terminate it like this:
TerminateThread ( hthread, 0 );
Just livin a dream.. dont wake me!
|
|
|
|
|
hello friends!
I had been told that we can not have resourses(.RC) like string table with our Win32 static Library. And if we had , then we hav to include .rc file along with the library file in an application using them.
Is it true! i yes is there any other way(except .DLL).
|
|
|
|
|
You have either been misinformed, or simply misunderstood. Resource-only DLLs exist and are quite common. Whether that DLL is implicitly (static) or explicitly (dynamic) linked to is up to the other application and has no bearing on what the DLL can contain.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Thx for the replies.
But i am totally confused now.
Can anybody elaborate more on this? can i have resource .rc along with .LIB file.???
|
|
|
|
|
A LIB file is platform independent. It is a set of routines, already compiled into machine language, and assembled together. Since they are platform independent they cannot contain any specific platform dependent information, like Windows resources. A LIB is a compiler loadable file.
A DLL, on the other hand, is a set of routines already compiled into machine language, assembled together, and wrapped into a platform dependent file. So, they can contain Windows resources, since DLL's are Windows format files. In fact, a DLL is a LIB with platform specific wrapping packed into an operating system loadable file.
The diference is in the last compilation process, the wrapping. That process also makes the closed wrapped form not usable statically (because DLL's are always dynamic, by definition). So, if your executable uses the code from a DLL then the DLL must be also made available (as a separate file) for Windows to load it when the executable is loaded (there are several ways to acomplish this).
A LIB file is not closed (it is not wrapped), so it may be placed inside the executable. In fact, as the compiler is building the EXE (or DLL) it can (and does) get code from various LIB files and puts it inside the EXE (or DLL). In all this process the resources have to come from somwhere other than LIB's.
There is a way to get around this. A LIB file is designed to contain both code and data. So, one trick is to declare a global variable, of type char [], that contains all the bytes you need your lib to have. You could write a simple program to convert any file into the corresponding C++ form. This program would do the following:
Read bytes of file "test.rc":
0x44 0x87 0x13 0x00 0xfa 0x60...
Generate the appropriate C/C++ file:
char test_rc[]={
0x44, 0x87, 0x13, 0x00, 0xfa, 0x60, ...
};
Then you could, at run time, obtain the buffer "test_rc" and its size "sizeof(test_rc)". This is a perfectly legal thing to do with LIB's. You could also write this data to a file, at run-time, for whatever purpose you like. My webservers work like this, the HTML pages are all contained inside LIB files, and I generate executables, DLL's, SO's (for LINUX), etc, all from the same LIB files. The advantage of this is that the executables are distributed without any additional garbage and are ready to run. Also, it becomes very difucult for someone to modify the pages I embbed in the executables 8because they are not Windows resources, and are, instead, part of the machine language LIB code).
However, I don't know how you could use this RC file in Windows at run-time... I know that you may specify resources at run-time when you use Win32 API functions, but with MFC I just don't know.
I hope this helps.
Rilhas
|
|
|
|
|
Hi rihas!
Thx a lot for the reply!
It made clear lots of things for me.
Thx again!
|
|
|
|
|
Hi All,
O.K so here is the problem. I'm trying to associate a process with a program that is currently running. i.e lets say winamp is running, and I want to monitor winamp, but I don't want to restart the process / kill the process, I want the new process to be associated with that one.
Process^ TEST = gcnew Process();
array<process^>^StartupApp = TEST ->GetProcesses();
TEST ->StartInfo->FileName = "winamp.exe";
CardSystem->StartInfo->WindowStyle = ProcessWindowStyle::Normal;
CardSystem->Start();
But see the above code will start a new session of winamp. I just want to assign the values of the process winamp to the process TEST.
If anyone could help or point me to a site on the net.
Thanx alot
Programm3r
|
|
|
|
|
Well, since this is the VC++ forum, and not the managed one, I would suggest using OpenProcess(...) to get a handle to the running instance of WinAmp. That is where I would start.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
one Managed C++/CLI
see James R. Twine answer and you can use CreateProcess
whitesky
|
|
|
|
|
Is it possible for me to link an SDI in my dialog based application? For example, when a button in the dialog is clicked, an SDI comes up.
I've tried to 'File->Add->New Project' and added an SDI project into my current project but i have no idea how to link them up.
|
|
|
|