|
are you trying to show between two button at the same position to do two different task ?
if so, i sugguest you not to use z-order but just change the object text of the button ( or CStatic ) by CWnd::SetWindowText(LPCTSTR lpszString) and if they are executable, set a flag ( i think you already have, which is "flip".. ) and in OnClick of that object, check the flag and do different task.. but as you said they are just static.. i guess you only wanna display different text SetWindowText can do what you need
|
|
|
|
|
I have an ATL COM DLL for a project I'm working on. It has a progress bar so some of our other COM objects can load and use it for showing progress...
At any rate, the Dialog is based on CAxDialogImpl. This dialog HAS a Cancel button so I don't want to override OnCancel. I tried overriding WM_KEYDOWN which works fine for any OTHER key pressed but for some reason doesn't capture the Escape key.
Anyone have any other ideas? Please help.
Matt Philmon
|
|
|
|
|
GetAsynchKeyState(VK_ESKAPE);
(in your OnCancel(...) to check the state)
|
|
|
|
|
THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU!
Matt Philmon
|
|
|
|
|
I have a CFormView which pops up a dialog box which has a property page. While in the property page, I want to get a value from the CFormView, but I can't, it always returns a wierd number like -814001 or somethign not even close to what I expect.
Can I please, please, email a small demo project to someone/anyone who could look at it and help me to get a value? Please please. My email address is brinasas@yahoo.com
This will probably take 1 line of code, but I am absolutely stumped and frustrated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
How are you accessing the CFormView class? Are you passing a pointer into the property page?
Michael
|
|
|
|
|
I am working on an ATL control that has a simple CStatic text label. While I've managed to change the font in both OnInitDialog and OnPaint I cannot change the color. Basically it is a Property Sheet with a CStatic control on it.
In the Constructor m_pArial is defined as:
m_pArial->CreateFont(40, 0, 0, 0, 700, 0, 0, 0, 0, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FIXED_PITCH, "Arial");
And it is deleted in the destructor.
Here is my code (it sets the font just fine - not the color).
void CPropPage::OnPaint()
{
CPaintDC dc(this); // device context for painting
CPen *pOldPen;
CPen BluePen;
BluePen.CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
CBrush Brush(RGB(0, 0, 255));
CBrush *pOldBrush;
pOldPen = dc.SelectObject(&BluePen);
pOldBrush = dc.SelectObject(&Brush);
m_Static_Title.SetFont(m_pArial);
m_Static_Title.SetWindowText("Test");
dc.SelectObject(pOldPen);
dc.SelectObject(pOldBrush);
}
Thank You
|
|
|
|
|
You need to do it in the WM_CTLCOLORSTATIC message handler
From MSDN on WM_CTLCOLORSTATIC:
"A static control, or an edit control that is read-only or disabled, sends the WM_CTLCOLORSTATIC message to its parent window when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the static control."
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
Does anybody know how to read and write individual bits of data to a file? I would appreciate any advice that you may have.
Thanks.
|
|
|
|
|
You have a lotof options,
You can use _read() function,
CArhive::Read() function Or CFile::Read() function.
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
You can write ints, BOOLs, doubles, etc.. like that, but not individual bits. Thanks though.
|
|
|
|
|
The minimum unit that can be written is a BYTE. Even the data type BOOL takes up a byte of space. So I think you can use 1 byte for each bit. But, if you want to write bits itself, you have to use the bitwise operators to fit it in the appropriate position in a byte and then write it to the file. A similar process should be done when reading.
- Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Thank you for your reply, that is what I figured I would have to do, although I really didn't want to.
|
|
|
|
|
Hello,
Does anyone know how to give a dialog box the ability to all ways be on top? eg.. even if some other app not related to yours is open (like your internet browser), I want my dialog app to stay on top..
Rob
|
|
|
|
|
This answer MUST be in the FAQ, but ::SetWindowPos (&wndTopMost, 0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
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.
|
|
|
|
|
Thanks Christian.. In the future, I'll do a little more searching before I post.
Thanks again for the fast response.
Rob
|
|
|
|
|
Hi,
I have a MFC test app with 2 edit fields. I want to pass the edit fields handle to an MFC ActiveX control which will just return the contents of these fields.
The problem I am facing is that ActiveX control does not allow to take in HWND as a parameter.
Is there a way to pass HWND in my activeX control.
Thanks in advance
Bobby
|
|
|
|
|
I'm not exactly sure what you're trying to do, but you can add an IUnknown derived interface and create a method that lets you pass the handles. You can also cheat and cast them to a LONG if you're using a dispinterface.
But for most stuff this doesn't seem like a good idea. What exactly are you trying to accomplish?
--CoolDev
|
|
|
|
|
Well basically my MFC activex control contains hook functions. So from my MFC test app if I pass a handle of the edit field, then my ActiveX control should process the information based on Hooks.
When I try to add a method to my ActiveX control, it doesnt allow me to add HWND as one of the argument. There is something called OLE_HANDLE instead but I dunno if that will solve the purpose.
Any help will be greatly appreciated.
Thanks
Bobby
|
|
|
|
|
It sounds like you're using a wizard, and the interface you're trying to add the method to derives from IDispatch. A handle is not an OLE Automation type. As I said before, you can create a new interface that's derives from IUnknown, or cheat and make your function take a LONG and then cast it as appropriate.
I do question the design, though. I don't see why an ActiveX control would ever want to hook a WndProc of a control in its container...
--CoolDev
|
|
|
|
|
Thanks again ..
I know it sounds wierd that an ActiveX control hooking to a WndProc of a container but it is kinda needed since when the control is downloaded then it will help me to analyze some data.
I tried the function that takes OLE_HANDLE and casting it appropriately but didnt work. I will give it a shot with LONG.
The other solution u mentioned is through ATL COM(in which I dont have my hands dirty)..is it possible through just MFC.
Thanks a mucho..
Bobby
|
|
|
|
|
I'm creating a synchronized queue where callers can register to have a function called after a specified timeout (or after the previous one has finished, whichever comes last). Everything works great, but I would like to extend this so that any thread can queue up items, and the callback is guaranteed to be executed on that thread.
Ideally, a function like SetTimerOnThread(DWORD dwThreadID, TIMERPROC lpTimerFunc) is what I'm looking for.
SetTimer() will call back on the originating thread, but the problem is that after it returns from the callback I need to set the timer for the next workitem, which may have been queued up from a different thread.
Posting messages to various windows would help, but might get hairy. I'm trying to build this so that it doesn't depend on a windprocs having direct knowledge of the queue, or the queue having direct knowledge of windows.
Another potential solution is to CoMarshalInterThreadInterfaceInStream the item when it enters the queue, and unmarshal just prior to executing it. The marshalling should take care of making sure everything happens on the right thread. I don't particularly like this solution though. It's overkill and the queue doesn't currently use COM.
Any suggestions?
--CoolDev
|
|
|
|
|
the callback is guaranteed to be executed on that thread
Wow, that's quite impressive requirement. What should happen if that thread is busy? Seems that you'll need some cooperation from the thread you want your callback to be executed on - for example, waiting for Win32 event when there's no work to do. When the event is in signaled state, thread picks up callback address from the queue and jumps into it.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
The idea is that it's on a timer, so it happens whenever the thread gets around to handling the message. (I'm not trying to do something like QueueUserAPC() without expecting the thread to be in a waitable state!) This requires that all threads using the queue have a message pump, but that will always be the case for this application.
If you do away with encapsulation and let a WndProc on each thread know about the queue, and have the queue store a handle to a window on each thread, than it would just be a matter of posting a message to the window once the timer has elapsed.
If MSDN didn't explicitly disallow it I could pass an HWND who's message pump lives on another thread to SetTimer() with the expectation that it would post a WM_TIMER message to that window after the timeout. If params I sent to SetTimer() included a callback then it could call the callback without having to handle WM_TIMER in each WndProc.
--CoolDev
|
|
|
|
|
I think you should use PostThreadMessage and place the call to message handling code inside the thread's message loop, since messages posted with PostThreadMessage have hwnd == NULL.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|