|
I remember having trouble like that. I did a colour picker dialog and made it so you could click anywhere on the screen to select colours. I'm loading the code right now to see what I did.
I set a timer in OnInit to go off twice a second and then do this:
if(nIDEvent == 42)
{
CPoint pt;
GetCursorPos(&pt);
CRect rc;
GetWindowRect(&rc);
if (!rc.PtInRect(pt))
SetCapture();
}
CDialog::OnTimer(nIDEvent);
In MouseMove I do this:
CPoint pt;
GetCursorPos(&pt);
CRect rc;
GetWindowRect(&rc);
if (rc.PtInRect(pt))
ReleaseCapture();
Essentially I found I had to release capture every time the mouse was in the dialog, and set it before it left, releasing it when people click.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Just an idea...
Create a second thread that shows a modal dialog...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I have a need for this quite often, and while I haven't gotten around to writing my own class to do it, I know of one that works very well. It's called PassiveDialog and comes with the ITCLib package(http://devcentral.iftech.com). If I look at the code (just to get ideas) I find they've overridden the DoModal function:
...
TRY
{
// create modeless dialog
AfxHookWindowCreate(this);
if (CreateDlgIndirect(lpDialogTemplate, CWnd::FromHandle(m_hWndParent), hInst))
{
if (m_nFlags & WF_CONTINUEMODAL)
{
m_nFlags |= WF_MODALLOOP;
ShowWindow(SW_SHOWNORMAL);
UpdateWindow();
Pulse();
}
}
}
...
And created a new Pulse function to pass messages back to the calling code:
...
// Check to see if we can do idle work
while (bIdle && !::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE))
{
if (!(dwFlags & MLF_NOIDLEMSG) && m_hWndParent && lIdleCount == 0)
{
::SendMessage(m_hWndParent, WM_ENTERIDLE,
MSGF_DIALOGBOX, (LPARAM)m_hWnd);
}
if ((dwFlags & MLF_NOKICKIDLE) ||
!SendMessage(WM_KICKIDLE, MSGF_DIALOGBOX, lIdleCount++))
{
bIdle = FALSE;
}
}
...
For more info, just go download the library. Keep in mind, though, that the code is ©. Hope this helps!
-Dave
|
|
|
|
|
hi all....
i have a problem... if I want to use the Right key or Up key....:
switch (nChar)
{
case VK_LEFT:
MessageBox("Left");
break;
case VK_RIGHT:
MessageBox("Right");
break;
case VK_UP:
MessageBox("Up");
break;
case VK_DOWN:
MessageBox("Down");
break;
}
so... why does VK_RIGHT and VK_UP not work? Is my Code right?
I'm a newbie.... please help.... or is my System not compatible?
|
|
|
|
|
Where are you catching this message ? I just did up a test app to see what would happen and in WM_KEYDOWN the above code worked perfectly.
You don't have accelerators attached to right and up, do you ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
ohh.. accelerators... no problems... no more
|
|
|
|
|
ALl toda today the Go To Definition fucntion in VC++ has been screwed up. It fails to find my new classes, and is often wrong about the location of other classes. It appears that whatever this info is stored in is no longer being updated.. but ic an't figure out what that is. I've tried doing a Clean, deleting the .ncb file, rebuilding from scrath, etc. No help.
On a related note - the same function frequently gets confused about teh locations of certain definitions. For example, it can't find the SFGAO_ flags - define in shlobj.h; it often takes me to some other location in my code, rather than to the actuial definition.
|
|
|
|
|
I have no idea what is wrong with your configuration/build. But the browse information is contained in the *.bsc file NOT the *.ncb.
Matt
------
Accept that some days you are the pigeon and some days the statue.
|
|
|
|
|
Tnanks for the tip. I was able to fix it by deleting EVERYTHING in the debug directory. I thought that Clean would do that - guess not.
|
|
|
|
|
Hi,
I have created an MFC dialog based application. I'm trying to use a third party .ocx control in my application. I inserted the control by
Project->Add to Project->Components and Controls. This added a couple of classes to my project.
I then created the control in my project using the class and making a call to Create(...).
This all works fine and does what it is supposed to do. However, I need to capture an event from the control, is there any way to do this? If I put the control on the dialog it will allow me to add the event to my dialog class but when I try to run the application, it doesn't even load, that is why I created the control calling Create(...).
Any help in capturing this event would be greatly appreciated,
Craig
|
|
|
|
|
1.Each ActiveX control has a specific event handling
On webBrowser ActiveX is very simple.
If you detail somehow maybe i can help you but your question is generic.
|
|
|
|
|
Hi,
I am using Property sheet control in CFormView. The problem I am having is, when I use the tab key tab stop is not going out from the Property page to formview. In other word it loops in property page and tab control.
Using Lay Out -> Tab Order I have set the first tab order on one of the button on my formview and then second to place holder of the property sheet. When I execute my application focus is in side the property page. It dose not recognize the button.
Please help me. I search on codeguru and codeproject, none of the artical talk about it.
Thanks
-Parul
|
|
|
|
|
I maked a nice exe program in mfc with the Wizard.
Now I need to convert it to dll file .
Who can to explain me simply how do I it ???
Please !!! It is very URGENT !!!
Thanks very much
lolo
|
|
|
|
|
|
Create a new dll (with project wizard).
Now, copy all cpp/h files which contain Your functions/classes/methods etc from exe project into dll project. Do not copy implementation of such classes like CWinApp. It should work.
|
|
|
|
|
Hi! I have such code in my application:
**************
BYTE* pBits = new BYTE[20*92];
memset(pBits, 255, 20*92);
HBITMAP hbm = ::CreateBitmap(30, 20, 1, 24, pBits);
//this returns valid handle!
//m_sBitmap - some CStatic on the dialog with SS_BITMAP setted
m_sBitmap.SetBitmap(hbm);
**************
The problem that i don't see the bitmap. CStatic works properly, i tryed to load bitmap from resource and this is worked, so i guess there is a problem with CreateBitmap function (or one of its parameters)
If you could help, please reply.
Regards,
Philip Patrick
|
|
|
|
|
Replace the 24 with the bpp of your screen. If you don't have a DC handy, you can do it like this:
CWindowDC dc(NULL);
GetDeviceCaps(dc, BITSPIXEL);
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thanx, I did like you say. It's working.
Thanx a lot
Philip Patrick
|
|
|
|
|
I am trying to add a CStatic item in the form of an icon to a dialog box and I am having no luck...
I have added this code to the OnInitDialog section:
CStatic myStatic;
myStatic.Create(_T("my static"),
WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50),
this);
myStatic.SetIcon( ::LoadIcon(NULL, IDI_QUESTION) );
Is there anything wrong that I am doing?
|
|
|
|
|
You can do that this way:
1. Insert a picture control on your Dialog.
2. In properties of this control enter Type: Icon and Image: IDI_QUESTION.
Jerzy
|
|
|
|
|
but if I want to do it on the run?
|
|
|
|
|
Add CStatic myStatic in your class.
In OnInitDialog():
myStatic.Create(_T("my static"),
WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50),
this);
myStatic.SetIcon(::LoadIcon(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_QUESTION)));
|
|
|
|
|
And one more question...
I am trying to use icon 161 in shell32.dll...
The default Icon in the file actually has a green background, but
typically this background is not shown in Windows dialogs. How do
you make the background match the background of the dialog while
the rest of items retain their original color?
|
|
|
|
|
Hi - I need urgent help. I need some Visual C++ code that will allow me to export a screen image as a BMP/GIF and to save the file. I would greatly appreciate anyone's help. I am a newbie and need to do this somewhat urgently. Thanks everybody!
Imran
|
|
|
|
|
there are plenty of examples on this site. look around.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|