|
Thanks for your reply,
Can you explain to me about friend functions ?
and How can i use of that ?
Other question,
What is this distructure:
virtual ~DClassName();
and what is difference with:
~DClassName();
???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
A friend method (i.e. function) can be shared by specific classes (i.e. friends of the class). You can also declare friend members, and can even make an entire class a friend of other classes. See http://www.cee.hw.ac.uk/~rjp/Coursewww/CPPwww/friend.html for an explanation of C++ friendship.
Using a virtual destructor in class CMyClass ensures that it (the destructor) will be called when an instance of a derived object (eg: CMyDerivedClass : CMyClass) is destructed. Virtual destructors are executed in reverse order - i.e. the derived class destructor is called first, followed by the base class destructor. If you don't use a virtual destructor, destruction will stop in the derived class.
Imho, you should always declare destructors virtual, and design your classes such that anything constructed by a base class is destructed by that base class.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I'm using "PutFile()" and "GetFile()" to transfer files between a client and a FTP server.
How can I retrieve a progress of this operation (maybe a callback), to put the transfer progress in a ProgressBar ?
|
|
|
|
|
Windows XP has extremly annoying AutoPlay feature. For my application I need to turn it off completely for all drives. I already made next actions:
1) Set "Take no action" for all drives and all content types (Drive Properties - AutoPlay)
2) Handle QueryCancelAutoPlay registered Windows message and reply "No, thanks" for all content types, as described in http://msdn.microsoft.com/msdnmag/issues/01/11/autoplay/autoplay.asp
3) Set DWORD value AutoPlay to 0 in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Cdrom
4) Set DWORD value AutoPlay to 0 in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk
However, there is still one case when Windows XP opens Explorer for DVD disk. In some place in my program I format DVD RAM disk using format command-line utility (I run it using CreateProcess). After disk is formatted XP opens Explorer window for it. May be there are some other things to do with this (except using Windows 2000, NT etc.)?
|
|
|
|
|
Hi, i have a problem, there are a lot of interesting activex controls - but they are loaded dynamicaly (or not?) so i'm not sure if all the users will have them - can you help me - are there some activex controls that are installed on every win machine ? For example there is "Microsoft Forms Checkbox" (or socalled) is it available on every win-box ?
thanks a lot for explanation
john
|
|
|
|
|
Hi, All !!!
=======
why doesn't it work ???
void qwewDlg::OnButton1()
{
CPaintDC dc(this);
dc.Rectangle(20,20,200,200);
}
Is it because I must draw everything under WM_PAINT ???
Why ??
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
did u read the docs for the CPaintDC stuff?
maybe there are't any dc's available when u make the call?
why would you want to do direct drawing out of the OnPaint code anyways? there are times when it makes sense but they are generally very few and far between afaik
---
"every year we invent better idiot proof systems and every year they invent better idiots ... and the linux zealots still aren't being sterilized"
|
|
|
|
|
Maybe I'm just wondering ?
Maybe I wanna try things ?
Maybe I'm just curious ???
Maybe blah blah blah ?????
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
You can't create a paint DC outside of WM_PAINT.
In this case, just use a CClientDC. (I think, it has been a while since I have used MFC)
void qwewDlg::OnButton1()
{
CClientDC dc(this);
dc.Rectangle(20,20,200,200);}
}
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Thanks
It works.
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
One more thing...
this works:
void qwewDlg::OnButton1()
{
CClientDC dc(this);
dc.Rectangle(20,20,200,200);
}
but this doesn't work:
void qwewDlg::OnButton1()
{
CClientDC dc(GetDesktopWindow());
dc.Rectangle(20,20,200,200);
}
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
|
Sagiv wrote:
Is it because I must draw everything under WM_PAINT ???
Yes. Imho, the right approach is to:- Maintain a list of objects drawn by your program. When the user clicks Button1, create a new "MyRectangle" object and add it to your list. Then call Invalidate(). This will instruct Windows to send your window a WM_PAINT message.
- In your OnPaint() handler, walk the list of objects and draw each one.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Dear all,
Can I use "typedef" with "class" ? (For some reason, I want to use "class" CA instead of "struct"..so..)
I mean, if I wrote the following things:
class CA
{
// omit
};
typedef CA* LPA;
I always got compile error like this:
error C2040: 'LPA': 'class CA' differs in levels of indirection from 'void ** '
How can I correct this error ? Anybody help me ?
Thanks a lot !
|
|
|
|
|
In my original program, I wrote:
class CRGBImage
{
// omit
};
typedef CRGBImage* PHANDLE;
So, I always got a compile error...
But, when I modified this line "typedef CRGBImage* PHANDLE;"
to:
typedef CRGBImage* PRINTHANDLE;
Then, everything is OK !!
Is PHANDLE a "reserved word" for MFC or Win32 SDK ?
|
|
|
|
|
Well, since HANDLE is a Win32 type, I'd expect PHANDLE (and LPHANDLE) to be typedef'ed.
--Mike--
My really out-of-date homepage
"Why does anyone have a web page? Too much free time... not enough friends... justifying owning a computer." -- Noel Crane on Felicity
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
True. A search for PHANDLE in Edit/Find and Replace/Find in Files with include directories setting gives
WinNT.h(288):typedef HANDLE *PHANDLE;
FaxDev.h(190):typedef BOOL (WINAPI *PFAXDEVSTARTJOB) (HLINE,DWORD,PHANDLE,HANDLE,ULONG_PTR);
|
|
|
|
|
How can a person use ASP pages and VBScript in a client side application, instead of just using html pages?
Nothing is impossible, It's merely a question of figuring out HOW?
|
|
|
|
|
|
I have a dll that launches a window from it. I do not want people to see the window it launches, instead I want the paint functions to be redirected to a Static box that I will place in my application. Does anyone know what I should look up or have any idea how this can be accomplished? Any help is appreciated!!!
Nothing is impossible, It's merely a question of figuring out HOW?
|
|
|
|
|
Why don't you just call ShowWindow( SW_HIDE ); on the window?
|
|
|
|
|
If I do use ShowWindow(SW_HIDE) to hide the unwanted window, how can I redirect the WM_PAINT messages to my new StaticBox?
Nothing is impossible, It's merely a question of figuring out HOW?
|
|
|
|
|
Some things are impossible. I think you've hit on one of them.
This is not simply a matter of redirecting WM_PAINT messages; you want a window in your app to display the contents of another, hidden window in a DLL. If it's possible, it will certainly be hellishly difficult.
|
|
|
|
|
What exactly are you trying to do? Are you trying to draw the contents of the window in the static box? If so, there are other ways of accomplishing that other than redirecting WM_PAINT messages. Give me details on what exactly you are trying to accomplish, and I'll help how i can.
D
|
|
|
|
|
Okay what I am trying to do is draw the contents of a window into my static box. My application loads a dll file and calls a function Init() in this dll. That Init() function will then Create its own window to draw in. Then when this window needs updating, I will call Render(...,...) and pass in the required parameters. The Render function from the DLL will the perform its calculations and then draw the result into the Window that it created when Init() was called. The DLL's containing these Init() and Render() functions are created by users so I will have no way of knowing what window class name the user created their external window with. I am trying to find a way to Hide that Window that is created in the Init() part of their dll, and then to draw its picture into my static box on my application each time I call Render(). I thought maybe I could do this by hiding the window and redirecting the WM_PAINT messages, but there are two problems with this, 1) a hidden window gets no paint messages and 2) I will not know what to paint since this is pre-determined by the user's DLL Render function. I thought I could do it with a bitmap srccpy and then paste it into my static box, but then I still have to have a way to hide the window. This Render function may get called upwards of 16 times per second so using ShowWindow(SW_HIDE) and ShowWindow(SW_SHOW) is not an option. I can use EnumDesktopWindows along with (HMODULE)GetWindowLong(hwnd,GWL_HINSTANCE) and compare this with GetModuleHandle("users.dll") to see if I have the window handle created by the user's dll Init() function. After I have the HWND by enumerating the windows, I now need to figure out how to hide the window, and then paint the contents into my static box every time the Render() function is called. The function names will always be the same, however the windows created and contents drawn inside these functions will vary depending on the user's dll file.
Nothing is impossible, It's merely a question of figuring out HOW?
|
|
|
|