Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all 21916 articles
Browse latest View live

Label hides behind other controls. ZOrder doesn't bring it to the front.

$
0
0
Hi.
I have a form with a lot of controls on it (SSTabs, Frames on the SSTabs, Textboxes, checkboxes, etc. on the Frames, etc).
I have placed a label directly on the form (on the bottom of all the above controls), and I have set the Visible property of this label to False (because usually it must be invisible).
The purpose of this label is to show a message to the user in case something happens.
Let's say I show this message if a Commandbutton is pressed:
Code:

Private Sub Command1_Click()
  Label1.FontBold = True
  Label1.FontSize = 14
  Label1.Visible = True
End Sub

It works perfectly.

Now, I change the above code a little bit, to show that message in the middle of the screen:
Code:

Private Sub Command1_Click()
  Label1.FontBold = True
  Label1.FontSize = 14
  Label1.Top = 3000
  Label1.Visible = True
End Sub

This does not work. The message does not show.
And the reason is obvious: It is hiding behind all those controls (SSTabs, Frames, Textboxes, etc)

In order to fix this problem and make the message show, I use ZOrder as follows:
Code:

Private Sub Command1_Click()
  Label1.FontBold = True
  Label1.FontSize = 14
  Label1.Top = 3000
  Label1.Visible = True
  Label1.ZOrder 0
End Sub

But this STILL does not work. The message does not show.
I guess the label is still hiding behind all those controls (SSTabs, Frames, Textboxes, etc) even in spite of ZOrder being set to zero.
But, why?
And how can I fix this?
I need to show this message on the screen, on top of every other control.
How can I do that?
Please advise.
Thanks.

This isn't working right!! Resource file extraction data process

$
0
0
Dear VBForumers, here is ThEiMp talking to you, today here on in. I am looking to simplify the source code in this Code block tags, below. I wish to have the UserControl to execute the Video file, and play it in the ActiveX Control Object which is the Media Player Control for Windows 10 Professional. Then when the video is finished playing then to delete the file off the local disk and then to be in standby mode for another command by the end-user, even.
Code:

Private Sub UserControl_Initialize()
On Error Resume Next

Dim strBuff As String
     
    strBuff = StrConv(LoadResData("1", "WEBM"), vbUnicode)
   
    Open "c:\Temp\1.webm" For Output As #1
        Print #1, strBuff
    Close #1
   
    Shell "c:\Temp\1.webm", vbMaximizedFocus
End Sub

!! Thanks in advance !!

TabStrip control in vb6

$
0
0
I use TabStrip control in vb6.
I insert Tab1 and Tab2 in to TabStrip.On the TabStrip put PictireBox1/named ChoicePictureBox(0)/ and Frame1 .
On the PictureBox1 and Frame1 I put PictureBox2/named ChoicePictureBox(1)/and Frame2.
Once I Run the program,problem is that the Frame2 is visible on the PictireBox1!
I would like the controls placed on the PictureBox2 not to be visible on the PictireBox1.
Thanks!
Code:

Private SelectedTab As Integer

Private Sub Form_Load()
Dim i As Integer

    ' Move all the frames to the same position
    ' and make them all invisible.
    For i = 1 To ChoicePictureBox.UBound
        ChoicePictureBox(i).Move _
            ChoicePictureBox(0).Left, _
            ChoicePictureBox(0).Top, _
            ChoicePictureBox(0).Width, _
            ChoicePictureBox(0).Height
        ChoicePictureBox(i).Visible = False
    Next i
   
    ' Select the first tab.
    SelectedTab = 1
    TabStrip1.SelectedItem = TabStrip1.Tabs(SelectedTab)
    ChoicePictureBox(SelectedTab - 1).Visible = True
End Sub




Private Sub TabStrip1_Click()
    ChoicePictureBox(SelectedTab - 1).Visible = False
    SelectedTab = TabStrip1.SelectedItem.Index
    ChoicePictureBox(SelectedTab - 1).Visible = True

AnimateWindow broken post-XP?

$
0
0
I'm not sure when AnimateWindow quit working. I was sure it was working Ok even for a simple PictureBox in the past. But I can't get it working right for a UserControl either.

Something like a simple TextBox seems Ok yet, but I'm sure the issues necessary were addressed within common system controls like the one inside a TextBox.

This is broken on Windows 10 though it might work yet on something earlier:

Name:  sshot Broken.png
Views: 30
Size:  1.3 KB


I have two fixes but one has an awful flicker on Form Load (it has to make the UserControl visible to do a capture on it), here is the second one that works as desired:

Name:  sshot Fix 2.png
Views: 23
Size:  2.4 KB

Surely there is a better alternative though? The gyrations I'm going through seem beyond unnecessary.
Attached Images
  
Attached Files

[RESOLVED] how to get the button name that is pressed

$
0
0
hey
i have 10 buttons with index that each button has a diffrent name
my question is how can i get the name of the button that is pressed?
e.x
btn(1) name = salsa
btn(2) name = mambo
and so on
regards
salsa :)

C DLL Call from BV6

$
0
0
Greettings,

I have a C Dll I made, which exports decorated functions easely used in my VB6 program. However, there's another software I'm making which only accepts undecorated ones - I've adapted the output. For simplicity, I'm trying to make VB6 to accept also undecorated functions (so the DLL would be common), but without any luck...

Is there a way to do this in VB6? Or can it be done in VB.NET only, maybe?

I apreciate the help.

Kind regards,

JKpeler

Failed to read large sqlite table (vbRichClient5)

$
0
0
There is a large data table in my sqlite database, it has more than 30 fields, 12000 records, and this table has a lot of pictures.

I have been using Olaf's dhRichClient (previous version of vbRichClient5) to handle sqlite data. It has been working very well. But these two days it read data failed, I guess the reason is that there is too much data in the single table. So I switch to vbRichClient5 to handle Sqlite data, but still goes wrong.

The source code is as follows:

Code:

Set rs = New vbRichClient5.cRecordset
strsql = "select * from test1"
rs.OpenRecordSet strsql, conn, True

On XP:
The error code line is: rs.OpenRecordSet strsql, conn, True
The error message is: Rs-construction: Cannot allocate more memory!

On Win10:
The error code line is: rs.OpenRecordSet strsql, conn, True
The error message is: Cannot execute Select-Statement: database disk image is malformed (11)


I did the following test:

(1) If I changed the code line as follows:
strsql = "select 10000 * from test1"
then RC5 can read data correctly.

(2) If I changed the code line as follows:
strsql = "select 12000 * from test1"
then RC5 can't read the data

I guess the reason for the error is that vbRichClient5.cRecordSet will read all the table data into memory at once. How to solve this problem? Thanks in advance.



Edit:
I know ADODB.RecordSet can read data like this:
Code:

Dim adoRs As New ADODB.Recordset
adoRs.Open strsql, Cnn, adOpenForwardOnly

But there isn't a parameter similar to adOpenForwardOnly in the vbRichClient.cRecordSet.

how do i color each listsubitems?

$
0
0
hey
is there a way to color each listsubitem row?
e.x
first row name is salsa and the color is red
second row is mambo the color is green
this is the code i am using to load from the database
Code:

    Dim Rs As New ADODB.Recordset
    Rs.Open "Select * From PriceList Order By PriceName", CN
    LsVw.ListItems.clear
    Do While Not Rs.EOF
    Set itm = LsVw.ListItems.Add(, , Rs!PriceName, 1)
        itm.SubItems(1) = Rs!PriceColor ' Here i want the color
    Rs.MoveNext
    Loop
    Rs.Close

of course i need to loop to get for each name its color
appreciate any help
salsa :)

how to fix overflow error

$
0
0
Hello,
I am connecting a modbus device (RTU protocol) and I have a vb6 program to read and show the data from floating point registers of my device to textbox (i used mbmasterv71.ocx in this program):

Code:

Dim MyData(2) As Integer
Dim MyDataSwapped(2) As Integer
Dim fValue As Single

'******Get two 16bit registers and read into MyData Array******
For i = 0 To 1
MyStatus = MbMasterV71.ReadResults(hConnect, Slave_Address, Command, Address + i, MyData(i))
Next i
MyDataSwapped(0) = MyData(1)
MyDataSwapped(1) = MyData(0)

'*****Copy the data from the register array******
CopyMemory fValue, MyData(0), 4

Then show fvalue to a textbox
It work nomarly but sometime the overflow error appear in line: MyDataSwapped(0) = MyData(1)
But i don't know the reason. So i need someone help me fix this error

obfuscate tool

$
0
0
does anybody knows a free obfuscation tool to obfuscate my vb6 codes?

View Webbrowser body content

$
0
0
hi is it possible to view the content ie: post/get, referrer, request body of a http request sent by webbrowser control or see the response of the server? i know i can view it through fiddler but can i do this internally within my app?

How to represent a scatter (X,Y) in MSChart in VB6?

$
0
0
Hello! I am new using VB6 and I want to know how to represent one serie of points in 2D.
I have two vectors x and Y of three elements each one and I have to represent each pair of coordinates (X,Y) in the MSChart.
Thank you!

Printer ejecting blank pages non stop

$
0
0
Sorry if what follows is a bit vague, I'm just looking for some suggestions about where to look because
I haven't been able to reproduce this.

Code pretty much identical to that below outputs a single sheet of printed paper on most printers but
I have had a couple of reports now that it causes the printer to start ejecting blank pages endlessly.

The printer scalemode in in pixels and the X and Y values are calculated by dividing the original twip values
by Printer.twipsperpixelX or Printer.twipsperpixelY

If anyone can suggest causes i should be looking for I'd be very grateful.

Code:

Dim c As Long
For c = 0 To UBound(arrPrintData)
    Printer.CurrentX = arrPrintData(c).XValue
    Printer.CurrentY = arrPrintDat(c).YValue
    Printer.Print arrPrintData(c).sValue
Next c


Printer.EndDoc

[RESOLVED] how do i color each listsubitems?

$
0
0
hey
is there a way to color each listsubitem row?
e.x
first row name is salsa and the color is red
second row is mambo the color is green
this is the code i am using to load from the database
Code:

    Dim Rs As New ADODB.Recordset
    Rs.Open "Select * From PriceList Order By PriceName", CN
    LsVw.ListItems.clear
    Do While Not Rs.EOF
    Set itm = LsVw.ListItems.Add(, , Rs!PriceName, 1)
        itm.SubItems(1) = Rs!PriceColor ' Here i want the color
    Rs.MoveNext
    Loop
    Rs.Close

of course i need to loop to get for each name its color
appreciate any help
salsa :)

Request for Non-US Res File

$
0
0
Question about resource files and VB...

I attempted to add a non-US unicode name (i.e, Chinese, Russian, etc) to a resource bitmap. For example, instead of 101 for the bitmap resource name, used: Добро пожаловать

The resource file was valid, though VB couldn't display it properly. I then compiled a test app with that resource & VB did so without errors, but changed the bitmap's res name to all ? characters when viewed in NotePad/WordPad. From what I've read is that MultiByteToWideChar calls are performed on those strings during compilation, which would explain what I'm seeing. If you are curious, I was able to do this by manually creating the resource file.

So, out of curiosity, for those that typically work in non-US locale while using VB, could answer a couple questions?

1) Does VB even let you use non-US character set when renaming a res file item?

2) If above question's answer is yes, then could you be so kind as to add a simple bitmap to a new res file, rename the bitmap from 101 to non-US characters and upload it here? I'd like to review it. I know I could probably do this by changing my system's regional settings, but fear it could be a flawed test if I did something incorrectly.

Note: I am not talking about string tables

Additional question for those far more knowledgeable than I. For US-locales, I noticed that VB forces upper case res item names when using string vs. integer names. I was able to use mixed case res names and both VB and APIs had no problems. Is this documented somewhere?

Edited: Mixed case is not applicable. After reviewing a compiled exe, in NotePad, with a res name using mixed case, the name was changed to all upper case. I think that whatever VB uses to compile resource files (rc.exe? something else?) into an app is doing these conversions. The conversions are only applicable to the app, not the original res file which still contains the mixed case & unicode names I'm playing with.

Regarding the unicode name I tried, VB actually loaded (and displayed the bitmap) from the res item fine, but APIs reported "resource not found" error when passing it the name I used. Thinking VB did a MultiByteToWideChar conversion which located the resource item, while passing the string pointer directly to APIs no conversion performed and APIs couldn't find it, because the name was converted to all ? characters when I compiled the app.

Permission Denied on iNet control after Windows 10 Update

$
0
0
Not sure this belongs here. Apologies if not. Hoping someone will have an easy answer...

I installed the new Windows 10 update (creative something or other) today, May 24th, 2017). Afterwards, when I opened my VB 6 program that was having no problems yesterday, I received following in a log file:

Line 14: Class InetCtlsObjects.Inet of control Inet was not a loaded control class.

When I tried to re-add the component (Project, Components, check 'Microsoft Internet Transfer Control 6.0'), I get permission denied. The path is to a new windows sub-directory SysWow64\MSINET.OCX. I tried running as admininstrator, tried running 'Take onwership' on the directory, no go. Also, tried adding the control by doing a Browse and going directly to the System32 directory and selecting it here, but it seems to hang.

Any assistance is appreciated,
nick

[RESOLVED] Failed to read large sqlite table (vbRichClient5)

$
0
0
There is a large data table in my sqlite database, it has more than 30 fields, 12000 records, and there are a lot of pictures in it.

I have been using Olaf's dhRichClient (previous version of vbRichClient5) to handle sqlite data. It has been working very well. But these two days it read data failed, I guess the reason is that there is too much data in the single table. So I switch to vbRichClient5 to handle Sqlite data, but still goes wrong.

The source code is as follows:

Code:

Set rs = New vbRichClient5.cRecordset
strsql = "select * from test1"
rs.OpenRecordSet strsql, conn, True

On XP:
The error code line is: rs.OpenRecordSet strsql, conn, True
The error message is: Rs-construction: Cannot allocate more memory!

On Win10:
The error code line is: rs.OpenRecordSet strsql, conn, True
The error message is: Cannot execute Select-Statement: database disk image is malformed (11)
(edit: I re-tested it and found that this error message on win10 was due to the sqlite-file being damaged)

I did the following test:

(1) If I changed the code line as follows:
strsql = "select top 10000 * from test1"
then RC5 can read data correctly.

(2) If I changed the code line as follows:
strsql = "select top 12000 * from test1"
then RC5 can't read the data

I guess the reason for the error is that vbRichClient5.cRecordSet will read all the table data into memory at one time. How to solve this problem? Thanks in advance.



Edit:
I know ADODB.RecordSet can read data like this:
Code:

Dim adoRs As New ADODB.Recordset
adoRs.Open strsql, Cnn, adOpenForwardOnly

But there isn't a parameter similar to adOpenForwardOnly in the vbRichClient5.cRecordSet.

[RESOLVED] Automating win zip program

$
0
0
Hello again to all

Could someone point me to info on using winzip inside a VB6 program?

After my program is done I would like to use win zip to compress and save that file/folder on a thumb drive

Thanks to all repliers

Jeff

How to improve the search efficiency and accuracy of the vbforums?

$
0
0
I often ask questions in the vbforums. I worry that it will affect others if I ask too many questions. So I prefer to search for answers in vbForums. But I found that vbForums' advanced search tool is very inconvenient.

When I search for an answer in the branch "Visual Basic 6 and Earlier", it always shows me other branch content, such as C#, VB.NET, ASP.NET, and so on. In fact, I just want to search for information in the branch "Visual Basic 6 and Earlier" and branch "CodeBank - Visual Basic 6 and Earlier". What should I do? Could vbForums improve search efficiency and accuracy (for example, add more search options )?

[RESOLVED] Detecting when user "clicks off" a modal form (in same application)

$
0
0
Ok, I'll outline the problem in simplest terms, and then I'll give a bit of background.

Here's what I'd like to do. Let's say a project starts with a Sub Main:

Code:


Option Explicit

Private Sub Main()
    Form1.Show vbModal
End Sub

And then Form1 looks something like this:

Name:  form1.gif
Views: 69
Size:  3.5 KB

And it has the following code:

Code:


Option Explicit

Private Sub Command1_Click()
    Form2.Show vbModal
End Sub

So, when you click the button, you get a modally loaded Form2.

Now here's what I'd like. If the user attempts to click Form1, without first closing Form2, I'd like Form2 to auto-close, giving the focus back to Form1.

Now, here's what I've tried. I've tried subclassing both forms, and here are the results. Form1 subclassing gives me nothing useful. All I get is mouse movements, but no clicks or anything else. (I don't want to close Form2 if all that's happened is the mouse has moved onto Form1. That's not enough.)

Ok, when subclassing Form2, here's what happens when Form1 is clicked. Obviously, the screen blinks, and Windows gives me the little dling sound. Regarding Windows messages, Form2 gives me WM_WININICHANGE, WM_WINDOWPOSCHANGING, and WM_NCACTIVATE. None of these seem particularly useful, as it seems they could happen just from the user twiddling around with Form2. Maybe the WM_WININICHANGE has possibilities, I'm just not sure.

------------------------

Ok, for a bit of background. In many places in my primary application, I have these little "Help" buttons to assist the user with the type of input that is being requested. For the most part, I stay away from any use of modal forms. That allows me to also show these "help forms" in a non-modal way. Therefore, it's easy to detect when they've lost the focus.

However, in a few rare cases, I do show forms modally for data input (the equivalent of Form1 above). And then, when I need to show a "help form", it must also be shown modally. And that's when I get into trouble. In all other cases, if the user clicks off the help-form, I just auto-close it. However, I can't do that with these modally loaded help-forms.

Just as further FYI, these help-forms have no user-interaction. Typically, all that's on them is information and a "Close" button. However, again, I'd like them to auto-close if the user clicks off of them.


Thanks for any advice/brainstorming,
Elroy

EDIT1: Just for grins, here's what one of these help-forms might look like. This would be the equivalent to a Form2 in my above example:
Name:  form2.jpg
Views: 75
Size:  58.5 KB
Attached Images
  
Viewing all 21916 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>