|
Hi,
in my app. i have this code:
The first part loads 2 bitmaps, 1 normal and one inverted one (used as a mask by windows):
HANDLE m_hImage;
HANDLE m_hNegImage;
m_hImage = LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_NORMAL), IMAGE_BITMAP, 0, 0, 0 );
m_hNegImage = LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB__INV), IMAGE_BITMAP, 0, 0, 0 );
Next i create a cursor with the info given:
ICONINFO info;
HCURSOR m_hCursor;
info.fIcon = FALSE; // means it's a cursor
info.xHotspot = 11;
info.yHotspot = 0;
info.hbmColor = (HBITMAP) m_hImage;
info.hbmMask = (HBITMAP) m_hNegImage;
m_hCursor = CreateIconIndirect(&info);
Next i override my OnSetCursor code to do my own implementation:
SetCursor(hCursor)
This code works absolutely fine under WinNT 4.0 but not under Win98. I imagine Win98 can't handle the size (rather big) of my own cursors. Anyway, all the functions return fine and work ok except it displays the standard cursor and not my own creation.
Does anybody have a clue on how i can still use my own images (and thus cursors) in my application under Win98?
Thanks
|
|
|
|
|
How I can get the list of availablis data members of the A class and their type, if there is an object or pointer on the object of the A class? (with C++ means only, w/o programming with assembler)
It is said, it is impossible.
Whether so it?
Thanks.
|
|
|
|
|
How can i display a ctrl in the dropdown window of a combo? for example a button?
or a checklist box?
|
|
|
|
|
Make the Combo box Owner Draw and derive a new class from Ccombobox and the control which u want to add
u also have to override various function (consult MSDN)
|
|
|
|
|
Hi,
I'm using a WebBrowser control inside a CView class. I've
used the ClassWizard to encapsulate the control's functionality,
but although I've used SetWidth() and SetHeight() to set
the right values, I can't get rid of the vertical scrollbar
on the right. SetResizeable(FALSE) returns a funny message,
and none of the CWnd scrollbar functions seem to have any
effect.
Any help will be greatly appreciated.
|
|
|
|
|
This can be done with the IDocHostUIHandler interface that you must implement in your container (CView derived class). Look at GetHostInfo and returning with docHostUIFlagSCROLL_NO flag set.
In ATL support for this interface is built in. You can look at the implementation of CAxHostWindow for an example implementation. A description of some of this can be found in ATL Internals.
|
|
|
|
|
void CDaTestView::OnInitialUpdate()
{
CView::OnInitialUpdate();
m_WebBrowserCtrl.SetLeft(0);
m_WebBrowserCtrl.SetTop(0);
m_WebBrowserCtrl.SetWidth(156);
m_WebBrowserCtrl.SetHeight(92);
if(m_WebBrowserCtrl.EnableScrollBar(SB_BOTH, ESB_DISABLE_BOTH) == TRUE)
TRACE("Cannot disable scrollbars!");
m_WebBrowserCtrl.ShowScrollBar(SB_BOTH, FALSE);
// Initialize the first URL.
COleVariant noArg;
m_WebBrowserCtrl.Navigate("file://D:/PROJECTS/MosaicLCD/default.html",&noArg,&noArg,&noArg,&noArg);
LPDISPATCH pDisp = NULL;
IDocHostUIHandler *pHostUIHandler = NULL;
pDisp = m_WebBrowserCtrl.GetDocument();
ASSERT(pDisp);
pDisp->QueryInterface(IID_IDocHostUIHandler, (LPVOID*)&pHostUIHandler);
ASSERT(pHostUIHandler);
if(pHostUIHandler)
{
DOCHOSTUIINFO *pInfo = NULL;
pHostUIHandler->GetHostInfo(pInfo);
if(pInfo)
{
if(((pInfo->dwFlags) & DOCHOSTUIFLAG_SCROLL_NO) == (pInfo->dwFlags))
TRACE("Scrolling enabled");
else
TRACE("Scrolling disabled");
}
}
if(pHostUIHandler)
pHostUIHandler->Release(); // release document's command target
if(pDisp)
pDisp->Release(); // release document's dispatch interface
}
I'm creating the m_WebBrowserCtrl in CDaTestView::OnCreate()
but I get an assertion in the line
pDisp = m_WebBrowserCtrl.GetDocument();
ASSERT(pDisp);
pDisp is NULL! Any idea why? Is there something else wrong
with this code?
Thanks in advance
|
|
|
|
|
You must wait for the DocumentComplete event from the Web browser control before you can get the document. Also you must implement the IDocHostUIHandler interface. The Web browser control will call your GetHostInfo method. You might be able to find some example code for this interface using MFC.
|
|
|
|
|
I want to use a MSchart-like bar-chart or pie-chart in my application . If I use the mschart.ocx in a dialog or a formview ,how can i print it? Or,if there is a easy way to get a method to realize the bar-chart and pie-chart,please tell me!
|
|
|
|
|
I've created container application that contains only one server. How can I make previewing this server from container?
|
|
|
|
|
Hi,
Does anyone know how to create child windows/controls in Visual C++ from an Add-In? I've seen
an add-in that makes Visual C++ look like Visual Basic by adding similar dialog bars, etc.. How can I
do that? Maybe there's COM interface for that?
|
|
|
|
|
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);
|
|
|
|