|
Can you give a url to that add-in?
|
|
|
|
|
How can I use the WinInet class to upload files from a local drive to server? If you know, please provide me some sample codes. Thanks.
|
|
|
|
|
Hi,
I have a problem with variable arguments.
I'll try to explain it:
Supposed there is a function, which is prototyped as follows:
int OriginalFunc(int n, ...);
Now I will add some code around this (bought) function like this:
HRESULT EnhancedFunc(sometype somevar, ...)
{
do some enhanced things with somevar;
do some more enhanced things;
// now I call the original function
if(OriginalFunc(?????????))
do some errorhandling;
do some *really* enhanced things
return S_OK;
}
So the question is how to pass a variable argument list through to another function which uses va too?
bye,
rootair
|
|
|
|
|
You can't directly. Instead you must call a version with the va_list arguments.
Its like the use of sprintf and vsprintf . One for this, one for that.
|
|
|
|
|
Thanks for the hint, but I already knew that. Unfortunately there isn't a va_list version of that function...
|
|
|
|
|
Can't you then just prepare the passed-in parameters, so that you pass 'em to the inner function with no ...-arguments?
E.g. the sprintf function can be used to pack all of your parameters into one and then go on.
E.g:
<br />
void myfunc( LPCTSTR param, ... )<br />
{<br />
CString formatted;<br />
<br />
OriginalFunc(formatted);<br />
}<br />
|
|
|
|
|
Hello,
I have an application that I need to use some ActiveX components with.
First let me describe the structure of the application and then the
problem we are having.
The application being developed is an add-on or extension for use with
third party applications. It is contained in a regular MFC DLL so that
it can provide the required "C" type calls for the host application.
Because it also has some user interface components it uses a dialog
based MFC structure to privide these. We used a regular DLL rather
than an extension DLL because the the "host" applications could be
written in any language and with any framework, it is an unknown
factor outside of our control. However, we did want to use MFC
internally.
The CWinApp instance in the DLL starts a modal dialog which acts as
kind of toolbar for the product. In the OnInitDialog method of this
dialog we create several other modeless dialogs for status and data
display.
Now to the problem. If we place an ActiveX component onto any of the
dialogs we get assertions and dialogs fail to create. As a example if
the ActiveX components are placed on the main dialog the debug trace
view shows the following text:
CoCreateInstance of OLE control {50548E24-4550-11D4-A9A7-00400516A5AD}
failed.
>>> Result code: 0x800401f0
>>> Is the control is properly registered?
Warning: CreateDlgControls failed during dialog init.
The error is CO_E_FIRST, Moniker enumeration failure. Whatever that
means.
So, could someone please give us a few pointers here. The InitInstance
method of the CWinAp instance in teh DLL has a call to
AfxEnableControlContainer. what more is required.
The component loads into the test conatiner just fine. It is also
visible and appears correctly in the dialog editor.
Any help or pointers much appreciated,
Thanks
Sid
|
|
|
|
|
I am thinking that maybe the OLE or COM Initialization has not occurred.
Isn't there usually a call like AfxOleInit() at the beginning of a MFC program? But maybe you are not getting that in your DLL.
Seems to me that you might need to call CoInitialize()
because the hosting program might not necessarily have done that, and your DLL is always running in some thread of that parent process, which means it does not necessarily have an initialization of OLE or COM going for it be default.
|
|
|
|
|
Thanks for the response. I think you are correct about the AfxOleInit call. What I have discovered is that the CWinApp object in my DLL is being created before the CWinApp object in the host application so the Ole init is not done when the dialog in the DLL tries to load the ActiveX component.
This has led me to have to rethink the startup of the DLL code because the host application may or may not initialize OLE. I think I need to delay the creation on my DLL based CWinApp object until the host is up and running fully. This is possible, a call already exists for the host to make for that. What may be more difficult is having the DLL know whether OLE is initialized or not so that if the answer is not it can do it.
Does this approach sound reasonable? Do you know if there is an API call that would tell the DLL if OLE init had been done?
Many thanks for taking the time to respond,
Sid
|
|
|
|
|
Hi
using the style LVCFMT_RIGHT in CListCtrl::InsertColumn(..) will right justify any text in any but the first column.
Anybody knows about that - is that by design or a bug and how could I get my first column right justified?
Thanks for any help
Solex
|
|
|
|
|
I think InsertColumn() works only with columns after the first, because you're adding a new column while the first already exists.
Try with SetColumn() instead.
Cheers,
Paolo.
|
|
|
|
|
Nope, that's by design. To get the text right-justified, you can use custom draw. See my article in the list control section for a tutorial on using custom draw.
|
|
|
|
|
Hi
solved it by first inserting a 0 width column - seems to work just fine.
Thank you all
Solex
|
|
|
|
|
Hi everybody!
I'm currently doing an app that set a printer current and set the paper size
without a PrinterDlg...
My problem is that it always return me the same margin size for any paper
size i set...
Do i do something wrong?
Here is my code:
HANDLE hPrinter;
CProBase pro;
DWORD dwBytesNeeded, dwBytesReturned;
PRINTER_INFO_2* pPI2;
HGLOBAL hDevMode;
DEVMODE* pDevMode;
CDC cdcPrinter;
CSize size;
// Open the printer and get an handle to it
if(OpenPrinter(pPrinterName, &hPrinter, NULL) == FALSE)
{
return FALSE;
}
// Fill the PRINTER_INFO_2 structure
GetPrinter(hPrinter, 2, NULL, 0, &dwBytesNeeded);
pPI2 = (PRINTER_INFO_2*)GlobalAlloc(GPTR, dwBytesNeeded);
if(GetPrinter(hPrinter, 2, (LPBYTE)pPI2, dwBytesNeeded, &dwBytesReturned)
== 0)
{
GlobalFree(pPI2);
ClosePrinter(hPrinter);
return FALSE;
}
ClosePrinter(hPrinter);
// Fill the DEVMODE structure with PRINTER_INFO_2
hDevMode = GlobalAlloc(GHND, sizeof(*pPI2->pDevMode) +
pPI2->pDevMode->dmDriverExtra);
ASSERT(hDevMode);
pDevMode = (DEVMODE*)GlobalLock(hDevMode);
ASSERT(pDevMode);
memcpy(pDevMode, pPI2->pDevMode, sizeof(*pPI2->pDevMode) +
pPI2->pDevMode->dmDriverExtra);
GlobalUnlock(hDevMode);
// Set the paper size
pDevMode->dmPaperSize = DMPAPER_TABLOID;
// Create an information context
if(cdcPrinter.CreateIC(pPI2->pDriverName, pPI2->pPrinterName,
pPI2->pPortName, pDevMode) == NULL)
{
return FALSE;
}
// Retreive the margins size
size.cx = cdcPrinter.GetDeviceCaps(PHYSICALOFFSETX);
size.cy = cdcPrinter.GetDeviceCaps(PHYSICALOFFSETY);
cdcPrinter.DPtoHIMETRIC(&size);
|
|
|
|
|
I used Get- resp. SetCapture in an MFC 6.0 Explorer-like application in a own button class. But: If the
capture is set to the buttons wnd, the mainframe doesn't receive any F-key message (didn't try other keys).
Does GetCapture also capture key-down messages?
Please help, this is an urgent project!!
|
|
|
|
|
Maybe the button holds the focus!
You can use mainframe's "PreTranslateMessage" virtual function to get the KeyDown message.
|
|
|
|
|
I try to build a class for an edit crtl with some special features.
I tried to overwrite my OnChar of the control.
Now the use my cursor has changed (I dont know why) to up=insertion cursor movesleft and down= insertion cursor moves right (left and right dont have any effect).
How could that be?
And I want to use a carrage return like a tab. Is this possible in the edit control? If it is how?
|
|
|
|
|
I would be grateful if anyone can help with this problem. I have an MFC Extension DLL called Base.DLL. It has a CFrameWnd derived class, CBaseFrameWnd. I next build a second MFC Extension DLL called Derived.DLL. In this DLL I add a class CDerivedFrameWnd, which is derived from CBaseFrameWnd. When I build Derived.DLL I get a problem at the linking stage...
DerivedFrameWnd.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CBaseFrameWnd::classCBaseFrameWnd" (?classCBaseFrameWnd@CBaseFrameWnd@@2UCRuntimeClass@@B)
DerivedFrameWnd.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const CBaseFrameWnd::messageMap" (?messageMap@CBaseFrameWnd@@1UAFX_MSGMAP@@B)
Can anyone explain what this is and how I can get round it? BTW, when I create a class derived from CBaseFrameWnd in an MFC AppWizard EXE project eveything works fine. I get no linker errors.
Thanks in advance.
|
|
|
|
|
The classXXX and messageMap symbols are the tip-off. I bet you forgot
DECLARE_DYNCREATE(CBaseFrameWnd)
in the class declaration, and
IMPLEMENT_DYNCREATE(CBaseFrameWnd, CFrameWnd)
in the .cpp file for the class. CDerivedFrameWnd will need similar lines (just change the class names).
|
|
|
|
|
Thanks for your reply. I used class wizard to add CBaseFrameWnd and CDerivedFrameWnd to BASE.DLL and DERIVED.DLL and so the DELCLARE_DYNCREATE and IMPLEMENT_DYNCREATE macros were added automatically.
When I first added CDerivedFrameWnd using class wizard, I specified the base class as CFrameWnd and then globablly replaced occurrences of CFrameWnd with CBaseFrameWnd. If I replace all occurrences of CFrameWnd except the two found in the IMPLEMENT_DYNCREATE and BEGIN_MESSAGE_MAP macros, then I get no linker errors. But this leads to problems like this...
I'm probably not understanding something quite fundamental here. I added a WM_CREATE handler in CBaseFrameWnd (OnCreate) which just does an AfxMessageBox. I would have thought that CDerivedFrameWnd should then show this message box when it is created. However, using the version that links (described above) - CDerivedFrameWnd does not display the message box (as expected, I suspect, as CFrameWnd is specified in the BEGIN_MESSAGE_MAP - not CBaseFrameWnd).
Thanks again for your help.
|
|
|
|
|
Mike, I searched the KB for "lnk2001 cruntimeclass derived" and found article Q128199 that might be of some help.
|
|
|
|
|
Many thanks, Mike. That KB article was exactly what I was looking for. The section "Limitations of _AFXEXT" solved my problems. Cheers!
|
|
|
|
|
I am trying to write a windows text editor that has a more attractive look (it looks a bit like sonique). But I am getting a memory leeks every time I redisplaying or resizing the app. I have separate functions to paint and resize the main window that I call when the appropriate message is sent to the app. And here seems to lie the problem because if I call them out side the msg look I don't get any memory leeks but it is very inefficient and untidy code. Here is the main gist of the message proc:
switch (uMsg)
{
case WM_PAINT:
DisplayWindow();
break;
case WM_MOUSEMOVE:
if (wParam == MK_LBUTTON)
{
SetWindowPos( hWnd,HWND_TOP,wdXPos,wdYPos,wdWidth,wdHeight,NULL);
} else {
CalcRGN(); // Calculate the windows new region
SetWindowPos( hWnd,HWND_TOP,wdXPos,wdYPos,wdWidth,wdHeight,NULL);
DisplayWindow();
}
}
Any help or a website that has got advanced windows programming tuts (ie stopping mem leeks) would be much appreciated
I am not using MFC because I want to learn as much about windows programming as possible.
|
|
|
|
|
From your code sniplet i can't see a leek, but the name of the function CalcRGN() suggest that you are using regions. A region is a resource which must be freed after using it, otherwise you get resource and memory leaks.
The leaks are caused by either of the function DisplayWindow() or CalcRGN() or both. Are you creating objects (regions or fonts ...)in those functions which are never released?
If you can't find anything then you better post the code of the two functions.
Hope this helps
|
|
|
|
|
Is it possible to make an item in a menu (CMenu ) visible/invisible at runtime (i.e. not just gray it out, but let it completely appear/disappear)?
|
|
|
|