|
With the funciton GetFocus()...
|
|
|
|
|
Sorry, I forgot how wacky the combo box is. I beleive the problem is that the CComboBox itself does not have the focus, the edit portion of it does, which is a separate window from the control itself. Thats what you need to be checking the focus for. I forget now how to get a pointer to the edit portion of the combo, but I think if you check around you will find how to get it.
|
|
|
|
|
|
See if this works (it did for me)
void CMyDialog::OnOK()
{
if( GetFocus() == m_Combo.GetDlgItem( 1001 ))
{
// Do combo stuff
return;
}
}
1001 is the id of the CEdit portion of the CComboBox.
|
|
|
|
|
Hello, the codegurus around the world.;)
Which situation do you want to work?
EditBox of ComboBox has the input fouce?
Or List of ComboBox is expaned and some item is selected?
when you push Enter key?
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hi there.
I'm trying to put often used functions into a dll. Since my projects make use of mfc I took the mfc-app-wiz. to create the dll. What I got was a class-body (not quite what I'd had in the Petzold years ago
I added a test-method to that class and compiled the dll. Adding it's .lib and header-file to a project got a linker error however (unresolved external) (I created an instance of the dll-class and called the test-method)
So the question is: how do I use mfc-app-wiz generated dlls in my projects?
Any help would be greatly appreciated.
Steffen
|
|
|
|
|
If my guess is right, you are adding the test method to the CMFCDLLAppWizCreatedApp class - this class is not exported, so the method won't be available.
Here's a simple class decl you could add where all the methods are exported:
class _declspec(dllexport) CTest {
public:
CTest();
virtual ~CTest();
};
Then, the bummer is that when you use the header in the consumer app you must use _declspec(dllimport) in the declaration instead. VC/MFC uses macros to get around this, switching on whether _AFXDLL is defined in the build (which you'll probably look at next).
You don't have to export the whole class, so you might want to use _declspec(dllexport) on your existing test method to um... test.
There's all manner of ins and outs to this, depending on the nature of your DLL. In the Petzold 16 bit world, you would have used a .DEF file with an EXPORTS section. This is not necessary in 32 bit, although it is still usefull if you want to do things like hide the functions from the dependency viewer etc.
HTH
|
|
|
|
|
As I saw/heard a lot of stuff on overriding WM_ERASEBKGRND and get OnEraseBkgnd to return FALSE to avoid flickering, I did that. The trouble is, What do you do if there comes a time when you actually want to Erase background upon OnDraw? Particularly if blitting is done with transparency, there would be a problem unless the client is first erased. Once OnEraseBkgnd is coded to return FALSE, it seems that calls like InvalidateRect(NULL,TRUE) won't erase background either.
Is there a general solution for this?
On a different note, how do can I keep receiving WM_MOUSEMOVE message in main frame even if cursor is hovering above something else, like toolbar or dialog box? Or even outside window frame?
Thank you.
|
|
|
|
|
if you want to avoid flickering use a double-buffer for your screen updates ... ie, draw to one off-screen buffer and blit to the screen when finished ... then draw the next frame to another off-screen buffer and blit that ... repeat as necessary
for the mouse stuff you can use SetCapture(...) and EndCapture(...)
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I am already using double buffering. My question was more to do with how to force a Bkgnd erase when WM_ERASEBKGRND is overriden to return FALSE at all times. That is, If there's a way to do so without using flags to conditionalize the return value of OnEraseBkgnd().
Anyway, I stumbled across another post which mentioned Invalidate(TRUE/FALSE)... and interestingly that works... Invalidate(TRUE) erases the background... so I think I found the answer. I still don't understand why this works though. But the first hurdle's overcome
Thank you for letting me know of Set/EndCapture. I'm still puzzled as to how to decide when to call EndCapture... as I want the mainframe to handle all mouse input & motion, even in floating dialogs outside the main window frame. I'll figure that somehow anyway. Thanks again.
|
|
|
|
|
I want to upload a big blob(more than 100M) to database(SQL Server 7.0). there a method named AppendChunk in ADO, but I use OLE DB in VC++6.0. Is anyone can tell me how to write a method function same as AppendChunk in ADO in VC++6.0 OLE DB?
|
|
|
|
|
I was wondering how to display the value of an integer in hex in a text box.
I have a variable of typ int assigned to the box, but I need to see the hex value.
Is their a way to set a flag as in the way you do it with cout?
Thanks James
|
|
|
|
|
How about this:
int number = 12;
CString s;
s.Format ( "0x%x", number );
m_wndMyEditCtrl.SetWindowText ( s );
-Ben
"Its funny when you stop doing things not because they’re wrong, but because you might get caught." - Unknown
|
|
|
|
|
Hi ! I'd like to make my application
show small animation based on icons.
I tried to do this with Picture control
because it supports icons and I've also found on the web an app in which bmps were loaded from .res into an array (but were drawn on the form not in the Picture control).I'm trying to do sth like that but with icons. Can anyone help me?
I tried those functions:
hIcon=AfxGetApp()->LoadIcon(IDI_ICON)
m_anim.SetIcon(hIcon);
//m_anim is CStatic from Picture
My icons are IDI_ICON1..IDI_ICONn. Does anyone have an idea how to make it using OnTimer funct. or maybe there is better way to do this.
I'm looking for working solution with some comments. Thanks.
|
|
|
|
|
One of Chris Maunder's articles is about animating a tray icon. You could probably adapt the code to work in your app.
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
I use this...
void CTestDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
X++;
if (X == 1)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
if (X == 2)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON2);
if (X == 3)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON3);
if (X == 4)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON4);
if (X == 5)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON5);
if (X == 6)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON6);
if (X == 7)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON7);
if (X == 8)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON8);
if (X == 9)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON9);
if (X == 10)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON10);
if (X == 11)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON11);
if (X == 12)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON12);
if (X == 13)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON13);
if (X == 14)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON14);
if (X == 15)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON15);
if (X == 16)
hIcon = AfxGetApp()->LoadIcon(IDI_ICON16);
if (X == 17)
X = 0;
m_anim.SetIcon(hIcon);
CDialog::OnTimer(nIDEvent);
}
|
|
|
|
|
Does anyone know if there are any tools that I can embed in my application to send huge files across a network??
|
|
|
|
|
There are many methods:
1. upload the file via Web Services(WWW Service). but you must install Web Server such as IIS in the server. you can upload the file in any size. I solved my problem in this way.
2. via windows Pipe.
3. via windows socket.
|
|
|
|
|
dont forget sergio 'the infomercial king' ... he found a way to tranafer 650mb INSTANTLY! across a MODEM CONNECTION!
heh
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Hi all,
I am trying to create custom edit control (with some additional features, one of them being bitmap background) by inheriting CEdit class. The problem is that background under the letters is erased/overwriten with background color. Does anyone know how to solve the problem? Any workaround suggestions?
Thanks,
Miha
|
|
|
|
|
can you not set the dc text bg to transparent?
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I have tried to change background mode, but I don't know how to get dc without manualy writing the text. I have tried to overwrite OnPaint function, but didn't help. The problem is that DrawText erases background under the text (as CEdit control does). Only background under letters is erased(not the whole area of the control) Is the catch in changing the BRUSH?
from OnPaint()
----------------------
CDC* dc = BeginPaint(&ps);
dc->SetBkMode(TRANSPARENT);
GetWindowText(m_cText);
dc->DrawText((LPCTSTR)m_cText, -1, &rect, 0 );
ReleaseDC(dc);
EndPaint(&ps);
----------------------
bye
Miha
|
|
|
|
|
yup ... catch the OnCtlColor(...) message and set the dc brush properties to what you require
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I have put my stuff in OnCtlColor (parent control) and it works
Thanks Lauren!
bye
Miha
Random code generator is the way to go
|
|
|
|
|
I have implemented printing within a MFC application.
I have a weird problem.
When I paint (BitBlt) a bitmap the Print Preview works OK.
However when I Print the page, only a black rectangle appears.
Apparantly I am doing something wrong.
Does someone had a similar problem and found the solution.
Thanks in advance,
Bert
|
|
|
|