|
also u can use your own printprew.i've seen the CView::OnFilePrintPreview() which is not complicable.
|
|
|
|
|
I'm not familiar with hook technics. Would you please give me more details,
or, if possible, a sample program or a segment of code show this method?
Thanks for your help.
Max
|
|
|
|
|
For instance, you can override PreTranslateMessage method.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thanks for your help.
I overrided the view's PreTranslateMessage() method, But unfortunately I found the printpreview disappears immediately after I pressed the Esc key before I can deal with the msg in the override.
Max
|
|
|
|
|
Using the SPY++ utility, I found the view has not even received any message except mouse msg's, e.g. mouse move, click, etc..
Then my override of PreTranslateMessage() will have no chance to paly any magic.
Thanks anyway.
Max
|
|
|
|
|
I'm subclassing TrayClockWClass on Win2K3 using a DLL hook. If I use an ANSI build of the DLL, the hook works with no problem. If I use a Unicode build of the DLL, I get a "The instruction at '0x00000000' referenced memory at '0x00000000'. The memory could not be 'read'." error in explorer.exe. When I click OK on the error dialog explorer.exe restarts and for an instant I can see my subclassed window instead of the normal clock.
I've placed some logging statements in the code. SetWindowLong() is successful. And my new WndProc() is being called multiple times with valid values. But it crashes for a reason I cannot determine. The last entry in my log is for a window message that was handled successfully multiple times.
And the weirdest thing is that TrayClockWClass is a Unicode window, so I figure it would get along with a Unicode DLL. I only plan to use the code on WinXP and Win2K3 so I'd rather use native Unicode rather than a thunked ANSI DLL.
Has anyone had any experience with ANSI hooks working, but Unicode hooks not working? Or any clues as to debugging what the problem is? If you want to take a look at the source code, a Visual Studio 2005 solution is in a Subversion repository (http://fuzzyclock.googlecode.com/svn/trunk/ fuzzyclock).
|
|
|
|
|
I don't know if this is relevant or helps in any way, but...
Testing on XP Pro SP2, Unicode DLL build:
During the SetWindowsHookEx() call, I get a "Data Execution Prevention" dialog with the message
"To help protect your computer, Windows has closed this program"
HookProc() is never callled.
Non-Unicode build runs fine.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
If I run the release Unicode build on XP Pro SP2, I get an unhandled exception in explorer.exe. But the log file I create (c:\log.txt) has output from HookProc():
SetWindowLong() returns 1001b1f. NewWndProc is c412e0. Thanks for taking a look. I guess I'll just stick with the ANSI build.
-- modified at 16:01 Sunday 22nd July, 2007
HookProc() needs to be _stdcall . Once I did that, the Unicode build worked.
|
|
|
|
|
Can someone tell me how big the BLUETOOTH_RADIO_INFO struct is? I believe it's 272. I'm trying to convert this into C# and I need to know the size...
typedef struct {<br />
DWORD dwSize;<br />
BLUETOOTH_ADDRESS address;<br />
WCHAR szName[BLUETOOTH_MAX_NAME_SIZE];<br />
ULONG ulClassofDevice;<br />
USHORT lmpSubversion;<br />
USHORT manufacturer;<br />
} BLUETOOTH_RADIO_INFO;<br />
<br />
typedef struct _BLUETOOTH_ADDRESS {<br />
union {<br />
BTH_ADDR ullLong;<br />
BYTE rgBytes[6];<br />
};<br />
} BLUETOOTH_ADDRESS;<br />
<br />
typedef ULONGLONG BTH_ADDR;<br />
#define BLUETOOTH_MAX_NAME_SIZE (248)<br />
<br />
|
|
|
|
|
Using the information you gave, using default packing [8] and using sizeof(), I come up with 520.
(I confirmed this compiling against the Windows Server 2003 R2 Platform SDK)
(Note that szName is WCHAR, so it has to be at last 496.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
sizeof(BLUETOOTH_ADDRESS) == 8
sizeof(BLUETOOTH_RADIO_INFO) == 520
As Joe mentioned, if you'll be passing between C++ and C#, make sure packing/alignment are the
same on both platforms.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
class Car<br />
{<br />
public:<br />
virtual ~Car() {delete itsCarb;}<br />
private:<br />
Carburetor* itsCarb<br />
};
Why is the destructor virtual here?
|
|
|
|
|
class FastCar : public Car
{
public:
virtual ~FastCar() { delete itsTurbo; }
private:
Turbo* itsTurbo;
}
FastCar* ferrari = new FastCar();
Car* car = ferrari;
delete car;
I think without the virtual destructor, FastCar's destructor would never get called if it's deleted using a pointer to a base class.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Car should have the virtual destructor. It doesn't matter if FastCar has one or not, unless you plan to extend that too.
|
|
|
|
|
True, but I was planning on writing a ReallyFastCar!
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
tom groezer wrote: Why is the destructor virtual here?
To ensure that the destructor from the most derived class will always be called.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Wouldn't it be better to do a search first?
Now, asking questions and such is perfectly fine, but I see 5 of your questions on the first page, and this one in particular, is a rather common topic.
|
|
|
|
|
Basically my question was whether virtual destructors could be used even if you do not have virtual functions in base classes. In the example that I have put I have not put any of the virtual functions.
|
|
|
|
|
The rule of thumb is that classes designed to be base classes that are used polymorphically should have virtual destructors. Classes such as yours without any virtual functions do not require a virtual destructor. Using a virtual destructor in this case wastes some bytes.
|
|
|
|
|
tom groezer wrote: Basically my question was whether virtual destructors could be used even if you do not have virtual functions in base classes.
That's all well and good, but you asked the same question here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How to get the text from the edit box of another application
|
|
|
|
|
Send it a WM_GETTEXT message.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi thx,
Can u expalin a bit more how to use this
|
|
|
|
|
You need to a handle to that window.
|
|
|
|
|
Knowing how to handle messages (both sending and receiving) is paramount in understanding the very basics of Windows development.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|