|
Hello all!
Anybody knows how to create Excel (BIFF) files without Excel (directly write to file)?
I find source code only in Pascal ((
Need C++ ...
Help!!! ))
Dmitry.
|
|
|
|
|
Hi,
I'm trying to write a bitmap conversion program that reads the bits of a bitmap file and writes them to another file in my custom format.
Because the user's bitmap might not be the required size, i want to scale it to cater for this eventuality.
The CDC::StretchBlt function is good for this, I've used it before. But how can I use this function, when i have no device contect to work with? I am not displaying the bitmap to the screen at any point.
How can i create memory device contexts from nowhere, that are suitable for my bitmap manipulation needs?
Thanks
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
::CreateCompatibleDC(NULL) will do, I guess.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for that info. It kind of works, but my stretchblt doesn't!
see:
CDC srcDC,destDC;
srcDC.CreateCompatibleDC(NULL);
destDC.CreateCompatibleDC(&srcDC);
destDC.SetStretchBltMode(COLORONCOLOR);
srcDC.SelectObject(m_Bitmap);
destDC.StretchBlt(0,0,WALLPAPER_SIZE_X,WALLPAPER_SIZE_Y,&srcDC,0,0,bm.bmWidth,bm.bmHeight, SRCCOPY);
int x,y;
for (y=0; y<WALLPAPER_SIZE_Y;y++)
{
for (x=0;x<WALLPAPER_SIZE_X;x++)
{
m_PreviewPane.p_ImgData[ (WALLPAPER_SIZE_X * y) + x ]=destDC.GetPixel(x,y);
}
}
OK. Let me explain what's happening here. I create a source device contect as you suggested, and a destination dc compatible with it. I select my source bitmap into the source device context (srcDC). I then try to strechblt, to scale the image to be WALLPAPER_SIZE_X by WALLPAPER_SIZE_Y in size. bm is a BITMAP structure, containing the source bitmap information.
Tracing through this in the debugger, everything seems valid. bm.bmWidth * bmHeight contain correct source size info, etc etc. But the stretchblt function returns 0 (which is a failure). GetLastError returns 0 as well, if i try that.
The nested loops at the bottom read the scaled bitmap into a previously allocated array. destDC.GetPixel always returns (COLORREF) 0xFFFFFFFF. if i change that line to use srcDC.GetPixel, It returns the proper data from my bitmap.
Basically, I have no idea why stretchblt is failing, and no ideas of how to trace through the problem.
Any help greatly appreciated.
Thanks
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
I fixed this now by using the CBitmapDC class from this site!
http://www.codeproject.com/bitmap/bitmapdc.asp#xx49439xx
Thanks all
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Anybody knows if is possible install with VC++ code the MS Jet 3.5 to access MDB files ? How could I make this ?
Thanks,
Cristiano ...
|
|
|
|
|
I want to open a URL using a NEW IE window rather than any existing one being reused (same as SHIFT+clicking a link in IE). Currently, to open a URL, I simply use ShellExeute, e.g.:
ShellExecute(NULL, NULL, strURL, NULL, NULL, NULL);
However, calling the above twice means you blat the first URL with the second...
|
|
|
|
|
First you need to determine what is the default browser on this machine. Check the "HKEY_CLASSES_ROOT\http\shell\open\command" in registry to find out it.
Next use your ShellExecute like this (in case the browser was MS Explorer):
ShellExecute(NULL, NULL, "iexplore.exe", strURL, NULL, NULL);
At least this way I did
Philip Patrick
|
|
|
|
|
Hi All,
I want to Create My own AciveX control which should work as teh usual database ActiveX Control.So Please give me the posssible suggessioon to create such a Component ie, what all are the Functions to be used for creating such an Application
Thanks in Advance
Sangeetha
|
|
|
|
|
Please email to me a copy,Ok?
thank you !
|
|
|
|
|
If you create a edit box and the create a int varible for that. Then compile it and erase everything in the edit box, then a dialog box appears with a message that says "Write an integer" or something like that. But HOW TO GET AWAY FROM IT!! I don't want it!!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
That is a work of the DDV function.
If you don't want have the message, you must fill edit box before close the dialog.
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
Override OnOK() and put a zero into the member variable you have associated with the edit box so that DDV wont complain.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Is there a way to export an entire class in a .def file? I am working on a Unix-based project and there may be a need to port it to NT. I really want to avoid all the non-portable __declspec(dllexport) and all of those macros.
Also, could someone tell me how the heap manager works for DLLs? I've heard that all memory allocated from one DLL must be freed by that DLL because it may be using a different heap manager... That seems like a major problem if it's true. How do people develop plugin DLLs if that is the case? Do people provide destroy() methods on every object created by the DLL so that it can delete it?
Cheers,
Andy
|
|
|
|
|
Hi Andy
I cannot provide you a proper answer but sometimes people create their own heap from their DLLs. Thus those DLLs must delete their private heaps.
Look up HeapDestroy,HeapCreate
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
As far as I know, .DEFs do not provide any means to export a whole C++ class in one fell swoop. The closest you can get is exporting all of the member functions and variables, but this is pretty complicated due to name mangling. This article discusses the issue in greater detail and proposes alternative approaches.
As for the DLL heap manager, I'm afraid what you've heard is true: best way to avoid problems is ensuring that all that is allocated in the DLL is freed by the DLL itself (this post of mine explains what the issues with DLL private heaps are). The most usual technique to deal with this problem is to have exported factory methods like create() and their corresponding destroy() s, as you pointed out. An implication of this is that crossed DLL objects should not be created on the stack (i.e. their ctors should be declared protected ).
If you still want to have classes that work safely across DLL boundaries but yet do not resort to create() methods, there's a solution: define and export new , delete and all ctors (including the copy constructor), and put the corresponding definitions in the .cpp file (so that they are not inlined). This way, all the allocation/deallocation works is ensured to be made inside the DLL.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
As for the DLL heap manager, I'm afraid what you've heard is true: best way to avoid problems is ensuring that all that is allocated in the DLL is freed by the DLL itself
Not at all. If you use the same version of CRT for the exe and the dll, you are safe. I do this all the time, and it works fine.
I vote pro drink
|
|
|
|
|
Well, my undersading of the situation (I explain it with much more detail here) is that the you're only safe if the CRT used is dynamically linked. Otherwise you end up with two (or more) CRT "instances", and two or more _crtheap private heaps. If I'm not wrong, it should be easy to prove this with a little test program/DLL combination producing a crash with statically linked CRTs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Oh, I didn't look at your link. Sorry.
It is true that I always use dynamically linked CRT. That's why I never had any trouble.
I vote pro drink
|
|
|
|
|
If you want your code to be portable take a look at how COM works. Define a creator function for your objects, and each object should manage his own life. So you don't care about heap managers, name mangling , etc, and as long as you stick with the C++ standard, your code will be portable.
|
|
|
|
|
Well, providing destroy() works well. And this is true that memory allocated in DLL must be freed in DLL. But when you created a new VC++ project, you can look in its properties, C/C++ tab, Code genertion and you will see "Debug multithreaded DLL" option selected which is by default. With this option you can use your memory as you wish (I mean in case of DLLs).
Exporting classes throw .def file is not allowed as I know.
How people making plugins? Simple. There are many different ways. Fisrt to have only raw global functions. But if you want to use class, write an abstract class (which is need only header file) and derive your plugin's class from it. Now provide global function in your DLL like "GetPlugin()", returning the pointer to the abstract class and call it from your application. This way you "exported" a class from DLL And this way I did some time ago
But of course, not so simple. My suggestion is to open MSDN and read about DLLs, there are many information about it
Philip Patrick
|
|
|
|
|
How do I disable a pushbutton in a dialog?? I've been round-and-round through MSDN. It can't really be that hard, can it??
~Cam Desautels (BinaryUprising.com)
|
|
|
|
|
EnableWindow ( hwndControl, FALSE );
--Mike--
http://home.inreach.com/mdunn/
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
|
|
|
|
|
or from MFC:-
CWnd::EnableWindow (false/true)
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|