|
Hi,
I have a CFormView-based SDI project in which I need to programmatically create & update an array of buttons in a view window. It seems that a CFormView would be the best class to use for this window, but I can't seem to create the window. What type of parent should the window have? I need to create it in the app's main CFormView window. Can that be done? Can anyone point me to a sample project?
Thanks,
Royce
|
|
|
|
|
A CFormView is basically a modeless dialog. It's nothing special really. What window fails to create? The buttons, or the CFormView?
--
Pictures[^] from my Japan trip.
|
|
|
|
|
The CFromView fails to create a window when the class ctor is called.
|
|
|
|
|
You cannot create child controls in the constructor, because the window is not created yet. You see, the CFormView object is nothing but a wrapper around a HWND (window handle). You will have much better luck if you create the child controls in OnInitialUpdate() (that is a virtual method which you can override, and is found in the classwizard).
All MFC window/control* classes are only wrappers around window handles, they are not windows themselves. They merely present a C++-friendly interface (some may disagree with this) to the messaging protocols which the window supports.
--
Pictures[^] from my Japan trip.
-- modified at 8:56 Sunday 4th December, 2005
|
|
|
|
|
Jörgen Sigvardsson wrote: They merely present a C++-friendly interface (some may disagree with this)
Aw, don't spoil his fun, Jörgen .
Software Zen: delete this;
|
|
|
|
|
Yes, I understand all that. It is the creation of the CFormview window that I am having trouble with. How and when do I create it? Must it be a child of a CFrameWnd? Can it be a child of another CFormView?
|
|
|
|
|
Hi, everyone!
My current project is an application to control the 3-axis table for the optical microscope. The each stepping motor can be controlled by the serial communication port using the ASCII text format.
Now, I would like to know which COM port is connected or not.
Is there any method to list the connected USB or COM port?
BaySeagull
|
|
|
|
|
Hi all:
I am writing a program which is a opengl like library. Finally I need to generate a bmp file to display the result. Does anybody know how to make a bmp file from c++ please???
Thanks a lot
Asura
|
|
|
|
|
Well, I guess a lot of examples you can get through the internet.
Anyway, the followings are my humble example.
<br />
<br />
BITMAPFILEHEADER bfh;<br />
BITMAPINFOHEADER bih;<br />
char* pBuffer;
<br />
<br />
bfh.bfType = ((WORD) ('M' << 8) | 'B');; <br />
bfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + lBuffer; <br />
bfh.bfReserved1 = 0; <br />
bfh.bfReserved2 = 0; <br />
bfh.bfOffBits = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); <br />
<br />
bih.biSize = sizeof(BITMAPINFOHEADER);<br />
bih.biWidth = pvih->bmiHeader.biWidth;<br />
bih.biHeight = pvih->bmiHeader.biHeight;<br />
bih.biPlanes = pvih->bmiHeader.biPlanes;<br />
bih.biBitCount = pvih->bmiHeader.biBitCount;<br />
bih.biCompression = BI_RGB;<br />
bih.biSizeImage = 0; <br />
bih.biXPelsPerMeter = 0;<br />
bih.biYPelsPerMeter = 0;<br />
bih.biClrUsed = 0;<br />
bih.biClrImportant = 0;<br />
<br />
CFileDialog dlg(FALSE, _T("bmp"), NULL,<br />
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,<br />
"BMP (*.bmp)|*.bmp|All Files (*.*)|*.*||");<br />
<br />
if(dlg.DoModal()==IDOK)<br />
{<br />
CFile file(dlg.GetPathName(), CFile::modeCreate|CFile::modeWrite);<br />
file.Write(&bfh, sizeof(BITMAPFILEHEADER));<br />
file.Write(&bih, sizeof(BITMAPINFOHEADER));<br />
file.Write(pBuffer, lBuffer);<br />
file.Close();<br />
} <br />
BaySeagull
|
|
|
|
|
Hai,
Please tell me that how to save a picture from client enviornment(CFormView) as Bitmap.
regards,
Jeeva
|
|
|
|
|
Hi, suprise! BN_DOUBLECLICKED wouldn't work! I want a button when single click do one thing, and when double clicked do another thing. but it never hit OnButtonDoubleclicked().
I search on Web, some one said, should change the button style to BS_NOTIFY, then I did check this style on property page. It made no difference.
Any one can help?
Thank you in advance.
|
|
|
|
|
|
Yes I went there before. I don't like the way to check double click. and I tried to check Notify option in property page, OnDoulbleClick() still could not be called. I still think there should be a better to do it. otherwise Wizzard should remove DoubleClicked notification from CButton.
MSDN says BS_USERBUTTON can get BN_DOUBLECLICKED notification. how to create BS_USERBUTTON?
|
|
|
|
|
Did you select Notify in Puch Button Properties - Styles dialog box?
|
|
|
|
|
Try to subclass the button and handle the double click
<marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" hspace="0" vspace="0">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I am converting an appln to unicode.
I use the code as follows
HtmlHelp(pWnd->GetSafeHwnd(), strHelpPath+="::/Popuptext.txt",
HH_DISPLAY_TEXT_POPUP, (DWORD)&popup);
but it throws up the following error
ExportDlg.obj : error LNK2001: unresolved external symbol _HtmlHelpW@16
ImportDlg.obj : error LNK2001: unresolved external symbol _HtmlHelpW@16
ReleaseUMinSize/ImportExport.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
when i include HtmlHelp.lib it says
LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
i have the htmlhelp.lib in current directory
what do i need to remove this error??
thanx in advance
|
|
|
|
|
actually u r linking with incompatible libraries for example
if you compiled one file to use one kind of run-time library and another file to use another kind (for example, single-threaded versus multithreaded) and tried to link them, you’ll get this warning.
You should compile all source files to use the same run-time library.
-- modified at 0:51 Saturday 3rd December, 2005
|
|
|
|
|
how to display a transparent gif picture
|
|
|
|
|
Can a C++ DLL developed with Microsoft Visual Studio .NET 2003 be used by Delphi, Borland C++ and other object-oriented languages? I am hoping to write a C++ DLL with ADO and CAsynSocket capability wrapped in some classes. Would there be any problem with Delphi, VB.NET, Borland C++ etc., e.g. name mangling due to different compiler vendors, if I export the classes in the C++ DLL? Can the Delphi, VB.NET, Borland C++ access and those exported classes? Thanks.
|
|
|
|
|
If you want cross platform/language, without giving into .NET, I advise you to go the COM route, as that's the only common denominator between the languages you mention (AFAIK).
--
Pictures[^] from my Japan trip.
|
|
|
|
|
So meaning that in this case I should wrap the C++ classes in a COM instead of a C++ DLL? Can Delphi, Borland C++ and other OOP languages use COM? What about a C DLL developed with Microsoft Visual Studio .NET? Can Delphi, Borland C++, VB .NET use the C DLL without any issue? Thank you very much.
|
|
|
|
|
Basically all languages and environments implemented for the Windows environmnt has support for COM, including C.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
If you wrap your C++ classes in a 'C'-style interface, then Delphi, etc. would be able to use your DLL. Note that you lose the notion of 'classes' then. Here's an example:
class MyClass {
public:
MyClass(int arg1,double arg2);
~MyClass();
void Function1(int arg3);
};
extern "C" {
typedef void *MyClass;
MyClass *MyClass_constructor(int arg1,double arg2);
void MyClass_destructor(MyClass *instance);
void MyClass_Function1(MyClass *instance,int arg3);
}; The DLL interface defines a 'constructor' function that will return a pointer to a MyClass object. The remaining functions take one of those pointers as their first argument. Note that you will need to be careful to explicitly the destructor function, since the user of the DLL is not C++, and doesn't know to call destructors when an object goes out of scope or is deleted.
Software Zen: delete this;
|
|
|
|
|
That's doable too. The good thing about COM though, is that you get marshalling for free, should you want to do outproc stuff.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Hi Jorgen, can I wrap the ADO (a COM) and MFC CAsyncSocket class capability into a COM? Is it workable if I develop the COM in Visual C++ and use the COM in Delphi, Borland C++ and other non-OOP languages? Any special codes that I need to add into the COM source so that it can cater for a specific language, eg a code section for Delphi and another code section for Borland C++? I would greatly appreciate if you can provide me some sample codes for developing COM in Visual C++ or any reference that I can refer to. Thank you very much.
|
|
|
|