I wrote a library which has a function call that returns a System.Drawing.Bitmap. Everything works great and I can access it just fine from a C# WPF application. However, now I need to make it work with a VB 6 application and for the life of me I can`t get it to work. I have a VB6 picturebox (note: this could be changed to an image control if necessary; we just need the image to display on the screen somehow) Right now I have tried the following unsuccessfully:
Set Form1.PictureBox1.Image = myImage <-- This causes invalid use of property on 'Form1.PictureBox1.Image'
Form1.PictureBox1.Image = myImage <-- This causes invalid use of property on 'Form1.PictureBox1.Image'
Form1.PictureBox1.Picture = myImage <-- This cause 'type mismatch'
Help please! I don`t know VB at all let alone VB 6.
Related
I have problem with button's caption in VB6.
I'm trying to change caption after "_load" event and it works, but new text is not in the center of the button - and it's a problem.
You can see it on the following screen:
https://dl.dropboxusercontent.com/u/3779161/buttons.png
I've tried to use "Refresh" function but without any effect.
Is it possible to refresh button without creating new one?
Thanks for help
I am unable to test VB6 code currently but, apparently, it requires Win-API calls to align the text. code here. Copy the code into a Module and then you can call the function AlignCommandButtonText. (Seems like hard work!)
the new text does center for me.
run the following test project and click on the form:
'1 form with
' 1 commandbutton: name=Command1 caption="Test"
Option Explicit
Private Sub Form_Click()
Command1.Caption = "New Test"
End Sub
the problem is probably caused by something else.
for example: do you have any tight loops?
could you post some of your code?
I have a GUI menu on Matlab with 4 buttons (menu.fig). Then I have 4 .fig file that I want to open when I click on the buttons. Here it's all ok, when I open a .fig from menu and insert value to do a plot I get this error:
???? Attempt to reference field of non-structure array.
If I try to open 1.fig directly, everything works perfectly.
I read that the problem is with eval(), but I can't solve it.
I changed the variable names on each .fig file
One 1.fig:
function pbutton1_Callback(hObject, eventdata, handles)
A1=get(handles.edtSAmp,'String');
f1=get(handles.edtSFreq, 'String');
fi1=get(handles.edtSFase, 'String');
t1=get(handles.popTipo, 'Value');
A1=str2double(A1);
f1=str2double(f1);
fi=str2double(fi1);
SinalSinusoidal(A1,f1,fi,t1);
I got the error on the that 1st line.
I guess this is something MATLAB GUI not handled well. I know it used to work, but when you tweaking your UI or UI related code a bit and accidentally you modified some area MATLAB told you not to touch, this kind of issue begin to happen.
The workaournd is to start the GUI from M editor by clicking run
I know it works, but originally, when I directly lauch it , it works too. so, this is not the end of it, people are just not getting to the end of it.
The problem is with probably with handles1. It's not a structure array like you expect it to be. In GUI's created with GUIDE, this variable is usually called handles, if you have both handles and handles1 make sure handles1 contains handles to the objects in the figure. If you're using handles1 only, make sure you're initializing it properly.
When I run my report from VS10, I have to switch everytime to print-layout. Because I need to make 100+ small adjustment to my big table, I have to press the print-layout button everytime to see the result.
Is there a way, I can set it up, so I start by seeing the print-layout when running the form?
It´s an old post but found the exact answer. Setting Print-Layout instead of setting Zoom mode for the ReportViewer.
ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
It looks like you can adjust report viewer properties. I found a adjustment that sets the zoom, in your case (print layout = whole page) so the default would need to be changed.
Here is the VB script for it from MS.
'Declaration
<CategoryAttribute("Appearance")> _
<DefaultValueAttribute(ZoomMode.Percent)> _
Public Property ZoomMode As ZoomMode
'Usage
Dim instance As ReportViewer
Dim value As ZoomMode
value = instance.ZoomMode
instance.ZoomMode = value
I don't know if you have to use a # like value = 50 or if you can use value = Whole Page, it seems like the latter can be used since it bases the figures dimensions on the logical page to assume the view size.
Goood luck and check http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer.zoommode.aspx for further guidance and different code options.
I've found a few tutorials that explain how to use the windows API to get a custom icon in the system tray.
These are all for Visual Basic, and they don't seem to be scaling to VBA well.
I'm following this short tutorial:
http://atchoo.org/vb/systray.php
Basically, you have to set the hIcon value (a 'long' variable) but it does not work.
I've tried to use the LoadPicture() function, which does not give me any errors, but also fails to add a new icon.
I can't supply Me.Icon, nor can I set it on Form_Load.
Does anyone have any experience with this?
Using loadpicture was the right approach, but not directly.
I had to define a new variable first, and load that.
Like this:
Dim myPicture As IPictureDisp
strPath = "F:\Databank\Icons\stone.ico"
Set myPicture = LoadPicture(strPath)
And then, somewhere along the way, I could set hIcon without problems:
.hIcon = myPicture
When I change the trayicon (like, say, adding a balloontip) I have to supply the icon information again, too.
Using VB 6
While running the Project, we cannot able to extend the form.
In run time, we put the mouse pointer in the Project form Layout border, it showing <-->.
It should not show to extend the form in the run time.
Am New to VB 6, How to write a code or set a condition?
Need VB 6 help?
You have to change the BorderStyle property of your form from Sizable (default) to anyone of the fixed variations (for instance Fixed Single).
Here's a screenshot of the property that controls this behaviour: