|
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.
|
|
|
|
|
I must admit that I have not used Delphi myself, but I do know that it supports ActiveX controls. In order to do that, there must be support for COM1. Borland C++ does have support for COM, that I know for sure.
COM is essentially a set of specifications. COM is built upon the notion that all components are communicated with through an interface. How the interface is represented in memory, is dictated by COM. Hence you will not need to provide different interfaces or implementations for each client language (Delphi, Borland C++, .NET-languages, etc). Write once in Visual C++ (or even Borland C++, VB6, .NET-languages, you name it), and use it in all COM capable client languages. Despite what Microsoft says, there were solutions for cross language development prior to .NET.
I should warn you though that COM has a rather steep learning curve. But in all honesty, books like Essential COM[^], and ATL Internals[^] makes that learning curve much flatter. ATL by the way, is a C++ class library, which takes care of much of the "boiler plate coding" needed for COM. It allows you to use wizards, as well as hand wire COM stuff quite easily. Should you chose the COM route, please use ATL. It'll spare your fingers from all that typing.
1 Well, to be honest, there doesn't have to be support for COM. It could be that all COM/ActiveX details are embedded into the language itself, shielding the programmer from COM. I doubt that though, because that would be utterly stupid, should the COM and ActiveX specifications change.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Agreed. I brought up my suggestion in case FFKONG needed something quick and simple (i.e. didn't have time to learn COM).
Software Zen: delete this;
|
|
|
|
|
Hi all,
this is my first time using port communcation, so I am a bit confused. I have read the msdn and several articles, but I still don't understand exactly how to do what I want.
Basically, I have a peripheral on my machine that I want to send messages to and receive messages from. I downloaded the CSerialCom[^] library from codeproject, so reading and writing is not a problem.
The problem is that the system requires programatic-management of control flow mechanish (DTR/DSR), which means that I must assert the DTR to get the peripheral's attention, and then I must wait for the DSR assertion before I can transmit data.
Can someone provide a demo that shows how to communicate with a peripheral with these contraints?
Thanks,
-----------------
Genaro
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/monitoring_communications_events.asp
and
http://www.codeproject.com/system/serial_com.asp
|
|
|
|
|
Thank you for your response. However, I still don't understand how to set the DTR high before monitoring for the DSR flag. Could you please explain that?
Thank you,
-----------------
Genaro
|
|
|
|
|
I think that you have null modem connection. DTR -> DSR are continual signal. When you set DTR signal on high that means you are redy to send data but when your DSR become high that mean you can receive data from device. When you start to configure port set DTR signal with DTR_CONTROL_DISABLE and fDsrSensitivity in DCB with TRUE to avoid flow, but watch all changing are valid after calling function SetCommState. Now you can control DTR with function EscapeCommFunction and monitoring DSR. My recommmendation is whenever use EscapeCommFunction(hFile, CLRDTR | CLRRTS ) or EscapeCommFunction(hFile, SETDTR | SETRTS).
|
|
|
|
|
Hi everyone
I'm in the first phase of a project where I just plan stuff, and it seems I'll be developing a plugin system for my app. I'm working in MFC, I don't really have much experience with dll's, there are still things bugging me (and we all hate bugs ) Now the questions..
a) Is it possible for the main app to load a dialog from dll and display it as a child window of tab control? or..
b) ..would it be better if the dll itself displays a standalone dialog using main app window as it's parent?
Which one of these would be easier to implement? Every dll would be a plugin, and giving the plugins an option to display windows is a nice thing to do.
c) Is there a way for dll plugins to add a menu to the main app window, and get notifications when the user clicks on them?
Any kind of help is appreciated, links to articles etc.. Also, if you have a good tip on plugin system development, please share it
thx
---
http://sprdsoft.cmar-net.org - We Sprd You Softly
Our site features contents and several images. All of this is very weird.
In the end, war is not about who's right, it's about who's left.
|
|
|
|