|
I writed regular dll in vc++ for delphi.
It works in vc client program but in delphi after the called function returned,
it performs illegal.
1.the function declared in the dll:
extern "C" _declspec(dllexport) BOOL Bin2Ots(LPCTSTR strBin,LPCTSTR strOts)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if(strOts == NULL || strBin == NULL){
return FALSE;
}
BOOL ret;
pCO = new CCO(strOts,strBin);
ret = pCO->Bin2Ots();
delete pCO;
return ret;
}
2. code in delphi:
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TfrmConvert = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
private
{ Private declarations }
public
{ Public declarations }
end;
function Ots2Bin(csvFile,binFile:String):Bool;stdcall;external 'OTSConvertBin.dll';
var
frmConvert: TfrmConvert;
implementation
procedure TfrmConvert.Button2Click(Sender: TObject);
var
aa :boolean;
begin
aa:= Ots2Bin(edit1.Text ,edit2.Text);
end
NOTE: the last line was performed already and the unknown error occured.But WHY???
PLEASE HELP!!!
Thanks in advance!
Wangqiujie
|
|
|
|
|
Try declaring your exported function as WINAPI :
extern "C" _declspec(dllexport) BOOL WINAPI Bin2Ots(LPCTSTR strBin,LPCTSTR strOts)...
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
#define WINAPI stdcall
this would make the calling conventions compatible.
|
|
|
|
|
You need to make sure that you have compatible calling conventions for the functions.
wangqiujie wrote:
function Ots2Bin(csvFile,binFile:String):Bool;stdcall;external 'OTSConvertBin.dll';
you will need to change this declaration to specify the calling convention of this function to cdecl, because this is the default calling convention in visual c++.
(csvFile,binFile:String):Bool;cdecl;external 'OTSConvertBin.dll';
either that or you can redeclare the function in your DLL to use the stdcall calling convention:
extern "C" _declspec(dllexport) stdcall BOOL Bin2Ots(LPCTSTR strBin,LPCTSTR strOts)
|
|
|
|
|
Great!
When i changed the declaration to
function Ots2Bin(csvFile,binFile:String):Bool;cdecl;external 'OTSConvertBin.dll';
It does work!
Thanks a lot!
...
Wangqiujie
|
|
|
|
|
Though I'm no Delphi expert, I think another possible source of error is that LPCTSTR s should be mapped to PChar s in Delphi, just like this:
function Ots2Bin(csvFile,binFile:PChar):...
begin
aa:= Ots2Bin(PChar(edit1.Text) ,PChar(edit2.Text));
end
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Could anybody tell me how to subclass windows system
clock window?
I want to handle my own WM_PAINT of clock window!
when I use the SetWindowPos and MoveWindow,I can only
change the position of clock window,But I cannot change
the size of clock window,How can I change the its size?
thans in advance!
|
|
|
|
|
I am not quite sure of what you are asking. It seems like you are asking two questions.
First, have you tried GetWindowLong and SetWindowLong with the GWL_WNDPROC as the index value? This is how you subclass a window.
You may have to see what happens in the WM_GETMINMAXINFO message when the window is sized, this is where you usually restrict the size that you can set for a window.
If this is not what you are asking for please clarify your question for me.
|
|
|
|
|
Thanks for your response
First I use the SetWindowsHookEx
Then I use SetWindowLong(hwnd, GWL_WNDPROC, (LONG)WndProc) to subclass
the clock window
In WndProc I handle the message that is send to clock windows
I want to change the size(specilly width) of clock window in WndProc
when I use SetWindowPos and MoveWindow,I just can change the its position
but cannot change the size.I didn't know why.
Can you give a way out?
|
|
|
|
|
devilsword wrote:
want to change the size(specilly width) of clock window in WndProc
when I use SetWindowPos and MoveWindow,I just can change the its position
but cannot change the size.I didn't know why.
I would override the WM_WINDPOSCHANGING message.
WM_WINDOWPOSCHANGED is where a window usually cancels any size commands that are sent to it. In your handler of this message simply return 0 as the message is handled in stead of sending the message to the clocks messages handler.
|
|
|
|
|
I can change the size now
First I subclass the taskbar proc
I use the MoveWindow func.It send the WM_SIZE to clock window
Then I subclass the clock window,I get WM_SIZE in my new clock proc
I handle it in clock proc.I found that the width has changed
I will try your message,I think it will be same result.
But when I add a tray icon to tray area,the size will be restore
Can you explain it?
|
|
|
|
|
Hi,
I have a bitmap in the resources, and I would like to print it, how can I do that ? ( there are a lot of problems when I try to do that, because the bitmap is DDB).
Or... How can I add a DIB to the resources ?
Thanks, Bye !
Braulio
|
|
|
|
|
Braulio Díez wrote:
I have a bitmap in the resources, and I would like to print it, how can I do that ? ( there are a lot of problems when I try to do that, because the bitmap is DDB).
What kind of problems are you experiencing?
Actually, device independant bitmaps (DIB) are the types of bitmaps that are stored in a resource file. Device dependant bitmaps (ddb) is the type of bitmap that is selected into a device context.
Let me know what you problem is and maybe we can solve it.
|
|
|
|
|
Hi,
The problem that I have is that I want to print a bitmap ( from the resources), to do that, I have to convert to DIB, to allow print it in the printer, and then use StretchBlt to scale it, but Now I cannot manage with the coordinates to print it ( it doesn´t print anything at all).
CDC memDC;
CBitmap BmpLogo.LoadBitmap(IDB_BERTHILDA_BASELINE);
memDC.CreateCompatibleDC(NULL);
CBitmap* pOldBitmap = memDC.SelectObject(&BmpLogo);
StretchBlt(
pDC->GetSafeHdc(),
0,
0,
20000,
20000,
memDC.GetSafeHdc(),
0,
0,
35000,
38000,
SRCCOPY
);
I´m just playing with the coord numbers to see if it paints at least something...
Thanks in advance, Bye!
Braulio
|
|
|
|
|
Braulio Díez wrote:
StretchBlt( pDC->GetSafeHdc(), // handle to destination DC 0, // x-coord of destination upper-left corner 0, // y-coord of destination upper-left corner 20000, // width of destination rectangle 20000, // height of destination rectangle memDC.GetSafeHdc(), // handle to source DC 0, // x-coordinate of source upper-left corner 0, // y-coordinate of source upper-left corner 35000, // width of source rectangle 38000, // height of source rectangle SRCCOPY // raster operation code );
is 35000 and 38000 the value of the bitmap in pixels, or have you changed the mapping mode of the image. Because as far as I know, there is a limit of how large an image StretchBlt can handle. I can't remember the limit but it is closer to 2500 x 2500 pixels.
I would suggest breaking the large image into smaller squares. You will have to create a for loop, and just walk your way across the bitmap painting a small grid of squares one after another.
To test if this is what the problem is, try loading a smaller bitmap that is only 100x100 pixels or something and painting that.
|
|
|
|
|
Hi,
That numbers was just a test ( I was trying with some numbers then some others then... whatever... ).
Finally I decided instead of using directly the DC of the printer just use a metafile and that worked fine, If I have some time will write one little article telling how to print a resource bitmap, I thought I was going crazy with that little stuff !
Anyway thanks for your help, Bye !
Braulio
|
|
|
|
|
I've been a little bit worried for the last couple of months. I've heard many of my friends that says that they have bought a C# book and the author recomends to start learn C# in almost every book!
But I don't want to start a new language because I have been doing with C++ in two years now and it hasn't give me any kind of problems during my learning!
So I ask you gurus out there, DO I HAVE TO START LEARN C# IF I PLAN TO BE A WINDOWS PROGRAMMER IN THE FUTURE (I'm 17 years old)?
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
You don't have to worry about C++ dying. Continue to learn and gain experience in C++.
However I would also recommend learning as many other languages as you can because C++ is not always the best tool. There may be a time when C# will be a better tool for you to develop a certain project in.
|
|
|
|
|
Rickard Andersson wrote:
I've heard many of my friends that says that they have bought a C# book and the author recomends to start learn C# in almost every book!
Well, what do you expect people who write C# books to say ?
The main reason I am so cynical of C# is that I feel I'm providing balance for anyone stupid enough to thing C++ is anywhere near dead. I'm certain M$ will push us towards C#, but I'm willing to bet the following:
1/ C# will prove to be a worthwhile tool for a limited subset of programming problems.
2/ For anything that seeks to get maximum performance ( games, graphics, etc. ), C++ will remain the best choice for some time to come
3/ Regardless of the hold C# takes, some people will continue to develop C++ apps on Windows, even if C# becomes a viable choice for all apps. There are still places writing non-legacy code and not using MFC.
4/ No matter what happens you will be better off for knowing C++, and from what I have seen, C# is not terribly difficult for people who know C++. It misses out on all the things that people can find confusing in C++, like templates and pointers.
I'd suggest you'd probably be wise to learn yourself some C#, but stupid to abandon C++.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
You are at an age in which you should try to learn as many languages as you can --including C# as well as C++, Java and more esoteric ones. A time will come when you'll find it harder or have less time to learn new stuff.
As for C++ being out of vogue for Windows programming when you start working (say in 5+ years), I don't think anyone will be able to give you a reliable prediction. Maybe some other language will go first place at GUI stuff, but when it comes to doing the hard job, my opinion is that C++ will be the best choice for a number of years to come.
So do not worry about dedicating yout time to learning C++, because it will be no wasted time, but keep an eye on every other language/technology around.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Rickard Andersson wrote:
a C# book and the author recomends to start learn C# in almost every book!
I'd be surprised to find a C# book where the author says, "C# sucks!"
You are only 17. You have so much time buddy. Learn C++/MFC/COM/C#/Managed C++....Learn them all.
When you finally get a job, these languages might have become extinct, but you will be fully ready for whatever the future has in hold for you
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
There will always be a need for C++ programmers. There are so many legacy projects out there that will exist for years and not be converted to C#. If C++ was going to die, Microsoft wouldn't have bothered with managed C++ extensions for .NET.
If you want to be a Windows programmer then C++ is the perfect place to start, if you want to be a web programmer then maybe C# is the way forward. Learn as many languages as you can and specialize in the one you like most.
Michael
|
|
|
|
|
Hi Rickard!
As a friend of the original writer and one of those guys who are spending a buck to buy a C# book, I felt a need to be a part of the discussion. The reason for me to buy my C# book and to start learn this new language was based on 2 factors.
1) MS have devoted 80 % of their development to the .NET(according to some book) and when microsoft spends that much cash into a new technology I thought it would be wize to listen. C# is the core language in visual studio 7.0 and I know C++ since before(but i suck on MFC unfortunatly).
2) Famous MFC authors like Jeff Prosise have said many good words about C# as the core language in the .Net framework sdk. I respect those guys alot. Even though you dont have to do or take their opinions to your heart, I did. Not just C# authors speak good of C# that is. And ofcourse, as in any other languages there is and will allways be ins and outs.
These are all but my humble opinions friends. I wish there was only one uni-programming language. A programming language suitable for any kind of programming. Easy to learn & easy to develop in. Yes I wish. But I also wish for world peace and for santa claus to really exist. Therefor, I guess you need a bunch of programming languages these days. C++ helped me understand other languages, and made it easy to learn PHP(which btw is an excellent alternative to Asp and therefor not microsoft dependant), and I will continue to learn C++. But I will study other languages too.
With regards !
Johan ranestal
|
|
|
|
|
i need to read numbers from a Textfile and store them in a linked list
so how do i read in from a file ?
please
|
|
|
|
|
You can use CStdioFile
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|