|
Hello!
I'm trying to use an ActiveX dll written in VB from my VC++ program.
After reading the article
http://www.codeproject.com/com/vb_from_vc.asp
I still have some problems.
I thought the compiler would generate error-free files for me to use!
In the project settings I have made the compiler create a h-file and a c-file when compiling the idl-file, which works just fine. Those files are included in my project, but then these errors occur when I try to build it.
1. In my generated c-file I get this error:
fatal error C1010: unexpected end of file while looking for precompiled header directive
2. I include my generated h-file in my dialog, but I get an error:
error C2061: syntax error : identifier '_sockdata'
The declaration in the h-file looks like this:
virtual /* [id] */ HRESULT STDMETHODCALLTYPE SendToServer(
/* [in] */ /* external definition not present */ _sockdata __RPC_FAR *MySesH) = 0;
Please, if you have any idea what I could do to solve the problem, give me a reply! Thanks!!
|
|
|
|
|
First you would have to disable pch(precompiled headers) for the files when you include them in your project. Second, you have to make sure that you include references to anything you add in your VB project. In this case try adding #import "c:\windows\system32\mswnsck.ocx" assuming that is what was included in your vb project for win sock ability. Add it before you include the header file generated from midl. An alternative to using this method is to include two lines in your stdafx.h.
#import "mswnsck.ocx"
#import "vb.dll" no_namespace named_guids // rename to correct name for your activx dll.
This should fix the problem. however, another may pop up depending on if you have anything other than the standard references or controls added to your vb project.
|
|
|
|
|
Thanks!
I also tried not including the c-file in my project which got rid of problem no 1...
"Time to give a Newtonian demonstration,
of a bullet, its mass and its acceleration."
-Stephen Hawking the gangsta rapper
|
|
|
|
|
I have a CAsyncSocket derived class.
int retval=m_inSock->Create(inport,SOCK_DGRAM);
this line causes creation of both UDP and TCP sockets at windows98.
The same problem is not appeared at Windows 2000.
i cauth that result by "netstat -a"
How come this is possible?
In release mode, program doesn't terminate.. giving the same errors and i have to reboot the computer to get out of it.
In debug mode everything seems fine.
Thanks in advance.
|
|
|
|
|
I am not familiar with winsock wrapper. Check the source code and make sure it does not call IPv6.
Kuphryn
|
|
|
|
|
|
Hi,
I have written a control using MFC. The control uses COleControl as its base class.
I can see a property called "Visible" when presented with the property list in Visual Basic.
I intend to change this value when I resize the control, however, I cant find a virtual override or a windows message that I can use to handle any change in this property.
Is there another way to get notification of change in the visibilty of the control in my form?
GB
|
|
|
|
|
Your control probably doesn't implemented "Visible" property -- it's an Extended propery provided by VB and implemented through agregation in your control.
Therefore, there is no way for your control to be notified through "Visible" property change notification.
However, you always have an option either:
1. to imlement DoVerb method IOleObject interface (check for OLEIVERB_HIDE,OLEIVERB_SHOW);
2. check for empty device context returned by GetDC on the window of your control.
There maybe some other more "advanced" methods...
Regards
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
It works! Thanks. Just have to remember how I was going to use it!
Also I noticed from MSDN that this should be visible via the ambient properties set but I couldn't find a #define for DISPID_AMBIENT_VISIBLE... which should be available according the documentation.
In fact I couldn't really find much detailed info about the ambient properties at all.
Regards.
|
|
|
|
|
Yes, DISPID_AMBIENT_VISIBLE is not available. Plus, don't forget that even if it does: it's up to the container to implement it or not. So, to have your control as much container independent as possible it is better not to rely on ambient properties being implemented (if possible).
Regards
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I need to process large files (> 2Gig). The regular C functions "fopen" or MFC CFile operate with a long value offset which limits the file to 2**31. Is their a other option than using low level routines ( _open, _lseek, ...) ?
Andre
|
|
|
|
|
|
In addition to Ian's suggestion, this article might be of interest.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thank you for the info. CFile64 needed integration, but did the trick! (Will I ever need CFile128?)
|
|
|
|
|
Andre1234 wrote:
Will I ever need CFile128?
If you do, just check back here and I'll suggest it to you!
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
One of the possible ways is to write wapper class similar CFile
specially assigned to manipulate with VLF.
F.e. - inside, this class could use 64-bit lo-level functions.
Thanks for the interesting question.
Vitali
http://www.creative-case.com
|
|
|
|
|
Use CreateFile() & CloseHandle()
Phil
|
|
|
|
|
I'm using the CMSChart class to plot a x-y scatter chart in VC, but the value of y data is much bigger than the x data, e.g. 100 v.s. 0.1, how could i set the scale of x and y coordinate to get a good appearance? Thank you!
|
|
|
|
|
you can use a logarithmic scale on the y axis.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Thanks for your resolution, but it still doesn't work! Because the scale of Y dataset is from 0 to 300, but the scale of X dataset is from 0 to 1, so i don't know how to plot them in a harmonic proportion. if i use logarithmic scale on the y axis, the Y axis will not be in proportion to the X axis. on the other hand, i can't change the scale of the axis.
e.g.: i have the following 5 points: (0.5,283),(0.01,186),(0.8,50),(0.1,11). how could i plot them?
Thanks again and have a nice day!
|
|
|
|
|
I have a Picture control on my dialog (taking up about 40% of the area).
I load several bitmaps during InitDialog as follows:
m_Image1.LoadBitmap (IDB_IMAGE1);
m_Image2.LoadBitmap (IDB_IMAGE2);
I have a member variable for the Picture control m_PictureImage
CStatic PictureImage;
Now when I click a button I want the Picture control window to be visable and then have the image loaded:
m_PictureImage.ShowWindow (SW_SHOW);
m_PictureImage.SetBitmap (m_Image1); // Button 1 pressed
All is fine but I need the Bitmap image to be resized, as don't always know its
size.
I cant fins any properties or methods to resize the Bitmap via the Picture control.
|
|
|
|
|
Use the functions of the parent class of CStatic in order to change size of the picture:
m_PictureImage.MoveWindow(0,0,200,300,TRUE);
You have to provide the new cooerdinates as Client coordinates (relative to the upper left corner of you dialog window).
You can also have its size to be equal to the exact bitmap size:
CSize size = m_Image1.GetBitmapDimension();<br />
m_PictureImage.MoveWindow(0,0,size.cx,size.cy,TRUE);
Peter Molnar
|
|
|
|
|
I added the following code onto one of the buttons:-
m_PrimaryFlight.LoadBitmap (IDB_FLIGHT);
m_Flight_Power_Images.SetBitmap (m_PrimaryFlight);
CSize size = m_PrimaryFlight.GetBitmapDimension();
m_Flight_Power_Images.MoveWindow(0,0,size.cx,size.cy,TRUE);
But no image appeared on the picture control, in fact size.cx and size.cy have the following values -858993460.
Note: m_PrimaryFlight is type CBitmap and m_Flight_Power_Images is type CStatic ( the picture control).
I am sure almost there, but one question @When adding control variable to the Picture control is iss of type CStatic, I would have though it would be of type CPicture.
Any comments?
|
|
|
|
|
Try to insert a line after
CSize size = m_PrimaryFlight.GetBitmapDimension();
by replacing CSize with some realistic value according to your loaded bitmap:
size.cx = ...; size.cy = ...;
In this way you will see whether the problem is with GetBitmapDimension() or MOveWindow().
Don't forget: the first parameters of MoveWindow are the upper left corner of your CStatic in client coordinates. If you code (0,0, size.cx,size.cy ...) then your Picture will be moved to the upper left corner of your dialog. If there is any other control at this position, your controls will conflict with each other.
Therefore try different values for the coordinates.
Peter Molnar
|
|
|
|
|
Still got a problem, GetBitmapDimension() return strange values (larger and negative) also MoveWindow just moves the bitmap (no resizing) to other locations on the dialog.
I thought that using the Picture control would be simple.
To recap it displays the bitmap(s) at the right location, just does not resize them to fill the required area; or in this case srink down the images to fit on the picture control.
Any other idears?
|
|
|
|