|
First of all.. I'm new to MFC
In my mdi app I have a class which derives from CRichEditView. Since I want to be able to use the extended capabilities of Rich Edit 2.0 I added this to my class.
BOOL MyTextView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
CCtrlView::m_strClass = "RICHEDIT_CLASS";
return CRichEditView::PreCreateWindow(cs);
}
This works fine except from when I try to create the window. The call to CreateWindowEx in CWnd fails, GetLastError returns 0 and I get the message that an empty document couldn't be created. It's feels like I'm on the right track but I have no idea what to do next
/Eric
|
|
|
|
|
|
I'm not sure how much work is involved here, but I'm trying to get a What's This (context sensitive help) button on the titlebar of a tool-style modeless dialog. i.e. I've removed the WS_EX_APPWINDOW style and added the WS_EX_TOOLWINDOW style to prevent the dialog from showing up in the taskbar. I've also added the WS_EX_CONTEXTHELP style to enable context sensitive help. The relevant line of code is in my dialog's OnInitDialog handler:
ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW | WS_EX_CONTEXTHELP, SWP_FRAMECHANGED);
I get help messages when a control on the dialog has focus and I hit F1, but the ? button on the titlebar is not drawn. It appears that the tool window style precludes the drawing of any buttons except the close button, but I haven't found any doc to support or refute this.
So my question is: has anyone figured out a way to "force" the drawing of the help button? I'd like to avoid custom painting and messaging code if possible, but I'll do what I need to.
Thanks,
Steve
|
|
|
|
|
Hey all!
I used ATL to develop an ActiveX control.
This control has it's own window (doesn't support Windowless operation).
I tried to add a message handler for the WM_KEYDOWN message and its friends, but my window doesn't receive those messages.
I also subclassed the rich edit control I use there for text (it would be sufficient for me to capture the key strokes that reach it) - but I want to capture Ctrl+B, Ctrl+I, Tab, Shift-Tab and Ctrl+F4 messages - and ALL of those key pressed are not even sent to the rich edit control - IE intercepts them and acts as if they were sent to IT!
What can I do?
Thanks!
|
|
|
|
|
I've got a COM addin DLL written in VB6 for Outlook2000 that makes calls into an MFC regular DLL written with VC++6. On both WinNT and Win2k this works fine. However when trying to run the application on a Windows 9x machine the VB6 part of the application works fine up to the point where it attempts to make the call into the VC++ DLL. I believe I have all the necessary dependencies copied to the proper location on the Win 9x machine and I am not using any NT specific code so I am stumped as to why this will not work. Anybody have any ideas for me?
|
|
|
|
|
Do you have any idea at what point its having the problem exactly, and if so, what does the code look like?
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
It's having the problem when the Visual basic DLL attempts to make the call into the VC++ DLL. For some reason this call is not taking place on the Win9x machine, but on the NT/2k machine it works fine.
The visual basic declaration of the VC++ dll function looks like this:
' Declare VC++ DLL function import
Declare Function IndexMsg Lib "OL_Index" Alias "IndexMessage" (ByVal msg_path As String, ByVal msg_note_path As String) As Integer
The actual call to this function looks like:
' Call VC++ DLL function to start the import process
result = IndexMsg((temp_path + MAIL_NAME), (temp_path + MAIL_NOTE_NAME))
On the VC++ side of things, the function declartion looks like:
extern "C" UINT IndexMessage(LPSTR msg_path, LPSTR msg_note_path);
And the implementation like:
extern "C" UINT IndexMessage(LPSTR msg_path, LPSTR msg_note_path)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// debug call to see how far the call goes
AfxMessageBox("Made it into Index func!", MB_OK);
// call the function to perform the indexing tasks
return theApp.DoDisp(CString(msg_path), CString(msg_note_path));
}
And finally my .DEF file for the VC++ DLL exports looks like:
LIBRARY "OL_Index"
DESCRIPTION 'OL_Index Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
IndexMessage @59 PRIVATE
|
|
|
|
|
I have been trying to create a CFormView (via Visual C++ 6 AppWizard) that will receive 6 parameter by way of the command line. I want to display each parameter in its own edit box. I have tried several different method of accessing the command line but most give some type of compile error (undefined, etc.). Does anyone have an example and explanation as to how to do this?
Luke Ratliff
|
|
|
|
|
there are dozens of ways to do this.
if you just want the command line parameters, you can use the __argv and __argc variables in you CWinApp::InitInstance the same way you use the argv and argc variables in a standard C program.
there are a number of command line utilities on this site, too. (i know, i wrote one of them)
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Hello,
I was thinking about making a application that pulls CString information from another program I have made and puts the information into a list control.. Where would be the best place to start on something like this?
Thanks,
Rob
|
|
|
|
|
Since you have source for both apps, you may want to use WM_COPYDATA.
|
|
|
|
|
Thanks! Right after you posted that I found this http://www.codeproject.com/threads/ipc_wmcopy.asp
Thanks again!
Rob
|
|
|
|
|
Hi,
I'm a bit clueless here really but I'm sure someone can help me out...
I'm using Chris Maunders MFCGridCtrl class. i want to trap a right click event on a cell. The documentation talks about overriding various "virtual" functions to achieve this.
How do I do this? because not of the grid classes appear in classwizard! I only know how to do this with classwizard.
Thanks
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
A virtual function means you can derive a class from the MFCGridCtrl class, and 'replace' those functions and things will work properly in terms of calls to the base class. So you need to create a new class, derived from the grid control, and then put in your own versions of those functions by hand.
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 for your help.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
I'm capturing a frame from a video stream. The data is being captured (I've verified that) as a 24-bit image. Part of the data being "captured" is the contents of the BITMAPINFOHEADER struct (again, this struct contains viable data).
I want to take this image and store it to the clipboard as a DIB.
Why doesn't this code work?
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader = cb.bih;
HDC hMemDC = CreateCompatibleDC(NULL);
HBITMAP hBitmap = CreateDIBitmap(hMemDC, &bmi.bmiHeader, CBM_INIT, cb.pBuffer, &bmi, DIB_RGB_COLORS);
if (OpenClipboard(NULL))
{
EmptyClipboard();
if (!SetClipboardData(CF_DIB, hBitmap))
{
}
CloseClipboard();
}
It always says that the hBitmap handle is invalid when I try to call SetClipboardData(). The hBitmap isn't NULL.
|
|
|
|
|
try using a real DC (instead of NULL) in your CreateCompatibleDC call. i find that these CreateCompatible things often only work with a real DC.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I tried the CreateCompatibleDC method, and the results are the same.
The SDK documentation says that if you pass NULL to CreateCompatibleDC, you get a screen DC. Why isn't that good enough?
|
|
|
|
|
that might be true..
i only metion that becaseu i find that doing something like this:
CDC memDC;
memDC.CreateCompatibleDC(pRealDC);
CBitmap memBMP;
memBMP.CreateCompatibleBitmap(memDC, ...);
will often fail (i get a monochrome bitmap or something equally perverse). To make it work I have to use pRealDC in the CreateCompatibleBitmap call. using the 'compatible' DC screws things up.
so, as a rule, i always use a real DC (from GetDC(NULL), or a paint DC or a CClientDC) in these functions.
just a thought.
also, when i copy DIBs to the clipboard, i do it like this:
HGLOBAL CISImage::MakeClipboardDIB()
{
HGLOBAL hDIB = MakeDIB();
HGLOBAL hCBDIB = NULL;
if (hDIB)
{
DWORD dwSize = GlobalSize(hDIB);
hCBDIB = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, dwSize);
if (hCBDIB)
{
BYTE *pCBDIB = (BYTE *)GlobalLock(hCBDIB);
memcpy(pCBDIB, (BYTE *)hDIB, dwSize);
GlobalUnlock(hCBDIB);
}
GlobalFree(hDIB);
}
return hCBDIB;
}
...
if (OpenClipboard(AfxGetMainWnd()->m_hWnd))
{
CISImage img;
...put something in img...etc.
HGLOBAL hDib = img.MakeClipboardDIB();
HANDLE res = SetClipboardData(CF_DIB, hDib);
ASSERT(res);
CloseClipboard();
}
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I can't find any reference to MakeDIB except for a MSDN sample app, and it requires parameters.
|
|
|
|
|
yeah. that's my own function. it just creates a typical BITMAPINFOHEADER and image data DIB. i'm assuming you already have a DIB floating around somewhere.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Wel, I have a populated BITMAPINFOHEADER and a shitload of captured bytes...
I've been trying to make a DIB that can be stored to the clipboard. Trouble is, I don't know what I've done right, and what I've done wrong.
Why does something like this have to be so hard in a *graphical* operating system?
|
|
|
|
|
sounds like you've got a DIB. have you tried displaying it (with something like StretchDIBits), just to be sure?
BITMAPINFO *pBMInfo = (LPBITMAPINFO)pDIB ;
LPVOID lpDIBBits = (LPVOID)(pDIB + pBMInfo->bmiHeader.biSize);
UINT32 lines = StretchDIBits(outHDC,
xPos, yPos,
outWidth, outHeight,
0,0,
inWidth,
inHeight,
lpDIBBits,
pBMInfo,
DIB_RGB_COLORS,
SRCCOPY);
that's the easiest way to tell if your DIB is correct/well-formed.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Yup, when I do a StrechDIBits, lines is equal to bmiHeader.biHeight.
|
|
|
|
|
hmmm.. have you tried the clipboard code i posted above?
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|