|
That's the way I do it, too.
It works fine
|
|
|
|
|
Good Day.
Im new to vc/services and ie automation.
How can i possibly automate ie in a winnt/win2k service to open a page in a local drive then hide some buttons after print it out.
Help extended will be highly appreciated.
Thanks
|
|
|
|
|
How can I load the images from the resource to the screen in fullscreen mode with autoresizing in addition I also wanna disable the PRTSCRN & ALT+PRTSCRN keys. How can I achieve this. I used the WM_KEYDOWN event but it isn't working for PRTSCRN & ALT+PRTSCRN. But When I all the buttons from my dialog box WM_KEYDOWN works for VK_UP & VK_LEFT but not VK_RIGHT & not even working for PRTSCRN & ALT+PRTSCRN.
Adeel Shamsi
adeelj@iname.com
|
|
|
|
|
>How can I load the images from the resource to the screen in
>fullscreen mode with autoresizing
The only way I know of is to (a) create a window whose client area fits the whole screen. This can be achieved by using
::GetSystemMetrics(SM_CXSCREEN) and
::GetSystemMetrics(SM_CYSCREEN),
and creating a CFrameWnd with no caption bar and non-resizing border.
To get the bitmap to full screen, you need to use StretchBlt() in place of BitBlt().
>in addition I also wanna disable the PRTSCRN & ALT+PRTSCRN keys. How >can I achieve this. I used the WM_KEYDOWN event but it isn't working >for PRTSCRN & ALT+PRTSCRN.
Any <alt> key combination generates WM_SYSKEYDOWN / UP.
WM_KEYDOWN or WM_KEYUP (not necessarily both) SHOULD work for PrintScreen (VK_SNAPSHOT is the key name). But try WM_SYSKEYDOWN / UP also.
>But When I all the buttons from my dialog box WM_KEYDOWN works for >VK_UP & VK_LEFT but not VK_RIGHT
Well, it should work the same for all arrow keys! But in a dialogue, there is some translation on keys to handle moving from control to control, swapping radio buttons in a group, etc. You should look at PreTranslateMessage() (in an MFC app - for a non-MFC app, I guess you need to get to the keypress before IsDialogMessage() is called), which is where the system does that translation. That should solve that bit of your problem.
As for the PrintScreen key, it is possible that it does not generate key messages to apps but instead is handled within the Kernel of Windows - in which case you are probably out of luck.
OK, I'll bite - WHY do you want to disable those keys? I hate it when apps try to disable keys and override the system. The system was designed for a reason, work with it! (You may have a very good reason, of course.)
|
|
|
|
|
I just able to diable the keys WM_SYSKEYDOWN/UP didn't work.
Below is the code for others
Disable the keys on app startup:
BOOL CTest1Dlg::OnInitDialog()
{
// My Code Start Here
m_nHotKeyID_1 = 100;
m_nHotKeyID_2 = 200;
BOOL m_isKeyRegistered_1 = RegisterHotKey(GetSafeHwnd(),
m_nHotKeyID_1,
MOD_ALT,
VK_SNAPSHOT );
BOOL m_isKeyRegistered_2 = RegisterHotKey(GetSafeHwnd(),
m_nHotKeyID_2,
NULL,
VK_SNAPSHOT );
ASSERT( ( m_isKeyRegistered_1 != FALSE ) ||
( m_isKeyRegistered_2 != FALSE ) );
// My Code End Here
}
Enabling the keys on app end:
void CTest1Dlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
// My Code Start Here
BOOL m_isKeyUnregistered_1 = UnregisterHotKey(GetSafeHwnd(),
m_nHotKeyID_1);
BOOL m_isKeyUnregistered_2 = UnregisterHotKey(GetSafeHwnd(),
m_nHotKeyID_2);
ASSERT( (m_isKeyUnregistered_1 != FALSE) ||
(m_isKeyUnregistered_2 != FALSE) );
// My Code End Here
}
Adeel Shamsi
adeelj@iname.com
|
|
|
|
|
Wow, I never knew about that function. Well done. I will keep that information for future reference. Sorry I couldn't help {:v(
|
|
|
|
|
is visual c++ 7 out yet, and is this different to visual c++ .net (or does it incorporate .net)?
and what is C#, is this version 7 or is it soemthing different altogether. I heard that MS are
moving to c# is this true? if so how different is it to c++, i heard c# was a mix btween visual
basic and c++ although the guy didnt really know what he was on about. Im just wondering as a
beginning programmer what should i use (as i am about to buy a copy of Visual Studio 6)...
also with the copy of visual studio im buying i dont get the msdn library (its a student edition),
thus is it possible/legal to copy the msdn CD. I figure because the informations publically
available on the net it might be free to distribute?? if im wrong then dont shout at me about this!
thanks in advance
|
|
|
|
|
Visual C++ 7 will be part of the Visual Studio.Net package or whatever they final decided to call it. As far as I'm aware Visual Studio.Net(VS7) will not be available until the beginning of next year.
Michael
|
|
|
|
|
My understanding (limited though it may be) is that Visual C++ 7 and Visual C++.NET are one and the same.
C# is Microsoft's new language that is specifically targetted at the .NET framework and is v. similar to Java. C# is another OO language and, like Java, has not wildly dissimilar to C++.
Microsoft are not moving to C#, it's very much a case of pick the language you want for the task in hand. VB, VC++, and C# all have different strengths and weaknesses nad are better at different tasks.
The tool you buy depends on your skillset. If you already know C++, then maybe Visual C++ is the best one to buy (from Microsoft's offering - they're not the only C++ langauge development tool vendor). Visual Studio includes Visual Basic, Visual C++, Visual Java and Visual FoxPro (does anyone use it;P ) and so if you have a number of these skills, then that is an even better option.
As for MSDN: I think the current licence agreement allows the MSDN Library to be installed on as many machines as you like within your organisation, outside of that the usual restrictions apply. As you rightly point out, all the information on the CDs is also available from the MSDN website.
Hope this helped. No doubt someone else will correct me in a few places
|
|
|
|
|
I am atempting to create a bitmap button that reacts to the WM_MOUSEHOVER & WM_MOUSELEAVE messages...
Here is the important stuff from the WindowProc:
// m_hDCClick, m_hDCOver, & m_hDCNoFocus are all HDCs that contain different images
// clicking on the button causes it to change the image properly
// but the mouse over events don't seem to work?
// however, the WM_MOUSELEAVE event does seem to work because the button does change back to
// normal when i click (holding down the left button) and leave the button area?
// my initial reaction is to think that the button window is not active... or on top?
// and that clicking on it brings it to the top and that is why the WM_MOUSELEAVE is working?
// but i'm not sure if that is the case, nor would i know how to fix such a problem?
bool _left_button_down = false;
bool _mouse_over = false;
.
.
.
case WM_PAINT:
{
PAINTSTRUCT ps;
::BeginPaint(hWnd, &ps);
if (_left_button_down) // if the left button is down draw the clicked image
::BitBlt( ps.hdc, 0, 0, m_Width, m_Height, m_hDCClick, 0, 0, SRCCOPY );
else if (_mouse_over) // if the mouse is over draw the over image
::BitBlt( ps.hdc, 0, 0, m_Width, m_Height, m_hDCOver, 0, 0, SRCCOPY );
else // else draw the idle image
::BitBlt( ps.hdc, 0, 0, m_Width, m_Height, m_hDCNoFocus, 0, 0, SRCCOPY );
::EndPaint(hWnd, &ps);
}
return FALSE;
case WM_LBUTTONDOWN:
_left_button_down = true;
::InvalidateRect( hWnd, NULL, false );
return FALSE;
case WM_LBUTTONUP:
_left_button_down = false;
::InvalidateRect( hWnd, NULL, false );
return FALSE;
case WM_MOUSEMOVE:
{
TRACKMOUSEEVENT lpEventTrack;
lpEventTrack.cbSize = sizeof( TRACKMOUSEEVENT );
lpEventTrack.dwFlags = TME_HOVER | TME_LEAVE;
lpEventTrack.dwHoverTime = 1;
lpEventTrack.hwndTrack = hWnd;
if(!::_TrackMouseEvent(&lpEventTrack))
{
MessageBox(m_hWndParent, "TrackMouseEvent Failed", "Error", MB_OK);
}
if( wParam != MK_LBUTTON )
{
_left_button_down = false;
_mouse_over = true;
::InvalidateRect( hWnd, NULL, false );
}
return FALSE;
case WM_MOUSEHOVER:
{
if( wParam == MK_LBUTTON )
{
_left_button_down = true;
_mouse_over = false;
} else {
_mouse_over = true;
_left_button_down = false;
}
::InvalidateRect( hWnd, NULL, false );
}
return FALSE;
case WM_MOUSELEAVE:
{
_mouse_over = false;
_left_button_down = false;
::InvalidateRect( hWnd, NULL, false );
}
return FALSE;
.
.
.
Thank You,
John
|
|
|
|
|
I am atempting to create a bitmap button that reacts to the WM_MOUSEHOVER & WM_MOUSELEAVE messages...
Here is the important stuff from the WindowProc:
// m_hDCClick, m_hDCOver, & m_hDCNoFocus are all HDCs that contain different images
// clicking on the button causes it to change the image properly
// but the mouse over events don't seem to work?
// however, the WM_MOUSELEAVE event does seem to work because the button does change back to
// normal when i click (holding down the left button) and leave the button area?
// my initial reaction is to think that the button window is not active... or on top?
// and that clicking on it brings it to the top and that is why the WM_MOUSELEAVE is working?
// but i'm not sure if that is the case, nor would i know how to fix such a problem?
bool _left_button_down = false;
bool _mouse_over = false;
.
.
.
case WM_PAINT:
{
PAINTSTRUCT ps;
::BeginPaint(hWnd, &ps);
if (_left_button_down) // if the left button is down draw the clicked image
::BitBlt( ps.hdc, 0, 0, m_Width, m_Height, m_hDCClick, 0, 0, SRCCOPY );
else if (_mouse_over) // if the mouse is over draw the over image
::BitBlt( ps.hdc, 0, 0, m_Width, m_Height, m_hDCOver, 0, 0, SRCCOPY );
else // else draw the idle image
::BitBlt( ps.hdc, 0, 0, m_Width, m_Height, m_hDCNoFocus, 0, 0, SRCCOPY );
::EndPaint(hWnd, &ps);
}
return FALSE;
case WM_LBUTTONDOWN:
_left_button_down = true;
::InvalidateRect( hWnd, NULL, false );
return FALSE;
case WM_LBUTTONUP:
_left_button_down = false;
::InvalidateRect( hWnd, NULL, false );
return FALSE;
case WM_MOUSEMOVE:
{
TRACKMOUSEEVENT lpEventTrack;
lpEventTrack.cbSize = sizeof( TRACKMOUSEEVENT );
lpEventTrack.dwFlags = TME_HOVER | TME_LEAVE;
lpEventTrack.dwHoverTime = 1;
lpEventTrack.hwndTrack = hWnd;
if(!::_TrackMouseEvent(&lpEventTrack))
{
MessageBox(m_hWndParent, "TrackMouseEvent Failed", "Error", MB_OK);
}
if( wParam != MK_LBUTTON )
{
_left_button_down = false;
_mouse_over = true;
::InvalidateRect( hWnd, NULL, false );
}
return FALSE;
case WM_MOUSEHOVER:
{
if( wParam == MK_LBUTTON )
{
_left_button_down = true;
_mouse_over = false;
} else {
_mouse_over = true;
_left_button_down = false;
}
::InvalidateRect( hWnd, NULL, false );
}
return FALSE;
case WM_MOUSELEAVE:
{
_mouse_over = false;
_left_button_down = false;
::InvalidateRect( hWnd, NULL, false );
}
return FALSE;
.
.
.
Thank You,
John
|
|
|
|
|
How can I set system hook that monitors ALL messages on WINNT based machine?I've try to write hook that inject all messages into DLL but when i'm starting hook with SetWindowsHookEx with NULL parameter for thread ID with which the hook procedure is to be associated messages that i'm receiving are only from window that is setting tha hook ?I need to watch for ALL messages on the system. I've try to pass as thread identificator ID of a desktop window thread but SetWindowsHookEx returns ACCESS_DENIED .Why?
Ivaylo Guberov
|
|
|
|
|
Hi !
To set system-wide hook you should place a hook procedure in DLL.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
I had this exact same problem. Here's the reason:
Whenever an app or DLL does something which triggers your hook, the system loads and maps a copy of your hook DLL into that process. Thus, the system has X copies of your DLL. Each DLL has SEPARATE data. Thus, the original DLL you load to run the hook is not aware of a variable being set in another instance of the DLL.
What you need to do is create a shared segment in your DLL, as follows (in the CPP file, not in any routine but out in the open):
#pragma data_seg(".shared")
HHOOK g_hHook = NULL ;
HWND g_hWndSelected = NULL ;
#pragma data_seg()
#pragma comment(linker, "/SECTION:.shared,RWS")
Any variable that gets set or used by the hook (except local variables, of course, since they are only temporary anyway) should be in this section so that ALL of the loaded DLL instances see that variable get the new value. For example, the hook handle above is used when calling CallNextHook(), since whichever instance of the DLL gets activated, it needs the handle to pass on. Similarly, if the activation code makes a note of the handle of a window being clicked by the mouse, then that window handle must be in the shared section (as the example above shows).
By doing the above, when your app that installed the hook goes to its original instance of the DLL and asks for the handle of the clicked window, your DLL can see the data even if another instance set it.
I hope that clears up the problem, it did for me
|
|
|
|
|
현재 프로젝트 안에 include란 폴더가 있는데
그 안의 헤더 파일이 두개 포함되어 있습니다.
지금 현재 프로젝트 화일에 분명 참조를 했는데...
도 계속 헤더 화일을 인식못하거든요?
어떻게 해야 할지 모르겠어요.
방법이 없을까요?
급한데... 보시면 답변 좀 부탁드리겠습니다.
|
|
|
|
|
Please translate your question... I think there's no people who know Japaness so good =)
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
here goes:
---snip!
// abc
class Base
{
public:
// pure virtual function
virtual bool Load (UINT nID) = 0;
protected:
Base (UINT nID)
{
Load (nID);
}
};
class Concrete
{
public:
Concrete (UINT nID)
: Base (nID) {}
bool Load (UINT nID)
{
// do the operation
}
};
Concrete c (123); // here's the problem
---/snip
this looks okay to me, but the linker complains that it cannot find the definition of Base's Load() member. My reasoning is that it shouldn't need it- it's never used except when its overriden... but?
does this have something to do with using a pure virtual function in a ctor? thats my guess, but it would be good if someone could point me towards the standard.
i'm using VC++ 6 sp 4
thanks,
Nick
|
|
|
|
|
Well this isn't much help, but I just tried your code using Borland's 5.5 compiler and it works fine. I get the same error as you when using VC++ 6 sp5.
|
|
|
|
|
heh... thanks
should have given it a run-over with gcc- i usually use that to weed out problems with vc++
cheers
nb
|
|
|
|
|
> does this have something to do with using a pure virtual function in a ctor?
I imagine your right. I think that if you call a pure virtual member within an a class that declares it, you are telling the linker to find the member it points to (in the VTABLE). The linker chokes because you have not defined one (obviously since it's declared as a pure virtual).
BTW: Why the protected ctor? Since Base has a pure virtual in it, it will never be able to be instantiated anyway.
-Ben
"Its funny when you stop doing things not because they’re wrong, but because you might get caught." - Unknown
|
|
|
|
|
Do NOT call a (pure) virtual function in a constructor or destructor. This can result in undefined behavior.
Think about it, or grab a copy of 'Stroustrup'.
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|
|
Thanks,
Now that I think about it... Base ctor called first, pure virtual function call would open the possibility for using unconstructed subclass data...
mmm
makes me worried that Borland C++ DID compile it! Thanks again to all of you
nick
|
|
|
|
|
I found this in the MSDN online help :
Another restriction is that if the constructor for an abstract class calls a pure virtual function, either directly or indirectly, the result is undefined. http://msdn.microsoft.com/library/devprods/vs6/visualc/vclang/_pluslang_restrictions_on_using_abstract_classes.htm
Borland compiled without errors, but didn't run correctly. I added printf function calls to the constructors and destructors of both classes. When I ran the program, the printf functions didn't output anything. When I removed the call for "Load()" in the base class, all worked as it should. I guess you could say that MSVC++ works better since it doesn't allow to shoot yourself in the foot.
|
|
|
|
|
In my program I need to use some mathematical (unicode) symbols like sigma, square root, integral, and so on. For some reason only some of the unicode works while others not. For example, I have an array Names and a CCombobox m_combo, and a loop to add the strings in the array to the combo box.
static const CString Names[] ="a","=",0x221A,0x222B,0x2211,0x2212, 0x223B};
for(int i=0; i<7; i++)
m_combo.AddString(Names[i]);
The combo box correctly displayed "a", "=", square root (0x221A), integral (0x222b),sigma (0x2211), minus sign (0x2212), but it shows only a square box for 0x223b instead of showing the symbol. This only happens to many other unicode characters.
Why some symbols can be correctly displayed while others not? Also how can VC++ convert a wchar_t into a CString automatically?
bob
|
|
|
|
|
Ok, I'd be very grateful if you can help me out here...
In my main dialog window, I fire up a new one. I that new dialog I want to have a CListBox (with values in it of course). I have no problem using the CListBox.AddString(...) in my main dialog.
Whenever I try to add a line in the new dialog the program crashes... Why? How can I do this the right way? I suspect the answer is very simple, I just can't figure it out...
The error message is: Debug Assertion Failed.
Cheers,
Erik
|
|
|
|
|