Public Class Form1
Const WM_NCHITTEST As Integer = &H84
Const HTCLIENT As Integer = &H1
Const HTCAPTION As Integer = &H2
Protected Overrides Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case WM_NCHITTEST
MyBase.WndProc(m)
If m.Result = HTCLIENT Then m.Result = HTCAPTION
Case Else
MyBase.WndProc(m)
End Select
End Sub
End Class
sábado, 20 de fevereiro de 2016
Vb.net - Mover formulário Transparente
quarta-feira, 3 de outubro de 2012
Selecionar texto em TextBox
quarta-feira, 30 de novembro de 2011
Visual Basic – Criando Gráficos
Para utilizar é bem simples, basta seguir os passos abaixo:
- Crie um novo projeto em VB6;
- Abra o menu de projetos e selecione Components;
- Selecione o controle Microsoft ChartControl 6.0(OLEDB) e clique em OK;
- No Form insira um controle Combobox e um MSChart;
- Cole o código abaixo na janela de código.
1 Private Sub Form_Load() 2 'Fill the combo box with different types of chart types. 3 With Combo1 4 .AddItem "3D Bar" 5 .AddItem "2D Bar" 6 .AddItem "3D Line" 7 .AddItem "2D LIne" 8 .AddItem "3D Area" 9 .AddItem "2D Area" 10 .AddItem "3D Step" 11 .AddItem "2D Step" 12 .AddItem "3D Combination" 13 .AddItem "2D Combination" 14 End With 15 'Declare 2D array to store values for the chart 16 'Variant ----so that can store both text as well as numbers 17 Dim X(1 To 7, 1 To 6) As Variant 18 19 X(1, 2) = "Steel" 20 X(1, 3) = "Aluminium" 21 X(1, 4) = "Copper" 22 X(1, 5) = "Buxite" 23 X(1, 6) = "Lead" 24 25 X(2, 1) = "JAN" 26 X(2, 2) = 2 27 X(2, 3) = 3 28 X(2, 4) = 4 29 X(2, 5) = 5 30 X(2, 6) = 6 31 32 X(3, 1) = "FEB" 33 X(3, 2) = 4 34 X(3, 3) = 6 35 X(3, 4) = 3 36 X(3, 5) = 10 37 X(3, 6) = 18 38 39 X(4, 1) = "MAR" 40 X(4, 2) = 1 41 X(4, 3) = 3 42 X(4, 4) = 8 43 X(4, 5) = 7 44 X(4, 6) = 9 45 46 X(5, 1) = "APR" 47 X(5, 2) = 4 48 X(5, 3) = 6 49 X(5, 4) = 13 50 X(5, 5) = 10 51 X(5, 6) = 12 52 53 X(6, 1) = "MAY" 54 X(6, 2) = 2 55 X(6, 3) = 9 56 X(6, 4) = 9 57 X(6, 5) = 12 58 X(6, 6) = 7 59 60 X(7, 1) = "JUN" 61 X(7, 2) = 13 62 X(7, 3) = 20 63 X(7, 4) = 5 64 X(7, 5) = 18 65 X(7, 6) = 11 66 '2D array is the data for the chart control. 67 MSChart1.ChartData = X 68 'Default chart type is se to 2D bar chart. 69 MSChart1.chartType = 1 70 71 End Sub 72 73 Private Sub Check1_Click() 74 If Check1.Value = 1 Then 75 'Show Legends 76 MSChart1.ShowLegend = True 77 Check1.Caption = "&Hide Legends" 78 Else 79 'Hide Legends 80 MSChart1.ShowLegend = False 81 Check1.Caption = "&Show Legends" 82 End If 83 End Sub 84 85 Private Sub Combo1_Click() 86 'To change the chart type at run time. 87 MSChart1.chartType = Combo1.ListIndex 88 End Sub
Resultado
sexta-feira, 2 de setembro de 2011
HTML acessando sheet name do Excel por VBScript
Abaixo segue o código HTML
Para testar crie um arquivo excel (.xls) no drive “C:\” chamado “TESTE2.XLS” e neste arquivo crie 6 planilhas. Este exemplo vai exibir uma caixa de mensagem contendo o nome e caminho do arquivo e todas as 6 planilhas existentes. A identificação das planilhas está fixa (hard-code) porém pode-se criar uma forma dinâmica para verificar todas as planilhas existentes no arquivo. Se alguém souber de outra forma como fazer seja em qualquer linguagem, por favor, comentem.
<HTML>
<HEAD>
<TITLE>Busca nome da sheet</TITLE>
</HEAD>
<BODY>
<FORM NAME="Form1">
<INPUT TYPE="Button" NAME="Button1" VALUE="Click">
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
Dim objExcel, strExcelPath, objSheet1, objSheet2, objSheet3, objSheet4, objSheet5, objSheet6
' Aqui eu verifico se existe a aplicação Excel instalada
' Isso eu não consegui testar
On Error Resume Next
Set objExcel = CreateObject("Excel.Application")
If (Err.Number <> 0) Then
On Error GoTo 0
Wscript.Echo "Não existe Excel instalado."
Wscript.Quit
End If
On Error GoTo 0
strExcelPath = "c:\teste2.xls"
' Aqui eu seleciono as sheets
objExcel.WorkBooks.Open strExcelPath
Set objSheet1 = objExcel.ActiveWorkbook.Worksheets(1)
Set objSheet2 = objExcel.ActiveWorkbook.Worksheets(2)
Set objSheet3 = objExcel.ActiveWorkbook.Worksheets(3)
Set objSheet4 = objExcel.ActiveWorkbook.Worksheets(4)
Set objSheet5 = objExcel.ActiveWorkbook.Worksheets(5)
Set objSheet6 = objExcel.ActiveWorkbook.Worksheets(6)
MsgBox "O nome do arquivo é:" & strExcelPath & vbcrlf &_
"O nome da sheet1 é: " & objsheet1.name & vbcrlf &_
"O nome da sheet2 é: " & objsheet2.name & vbcrlf &_
"O nome da sheet3 é: " & objsheet3.name & vbcrlf &_
"O nome da sheet4 é: " & objsheet4.name & vbcrlf &_
"O nome da sheet5 é: " & objsheet5.name & vbcrlf &_
"O nome da sheet6 é: " & objsheet6.name
' Aqui eu fecho a planilha Excel
' Se não fizer isso a planilha ficará presa, sugiro que isso seja tratado se ocorrer algum erro depois da abertura do Excel.
objExcel.ActiveWorkbook.Close
' Aqui eu fecho a aplicação Excel
objExcel.Application.Quit
</SCRIPT>
</FORM>
</BODY>
</HTML>
quinta-feira, 14 de abril de 2011
Scroll Mouse no VB
Baixe o ficheiro VB6 Mouse Wheel.exe que inclui a DLL do suplemento e o código usado para criar a DLL do suplemento.
- Baixe o ficheiro VB6 Mouse Wheel.exe. O seguinte arquivo está disponível para download no Centro de download da Microsoft:
Download the VB6MouseWheel.EXE package now.
- Para obter mais informações sobre como baixar os arquivos de suporte da Microsoft, clique no número abaixo para ler o artigo na Base de dados de Conhecimento:
119591 Como obter arquivos de suporte da Microsoft de serviços online
Microsoft examinou esse arquivo de vírus. Microsoft usou o software de detecção de vírus mais atual que estava disponível na data em que o arquivo foi lançado. O arquivo é armazenado em servidores com segurança avançada que ajudam a evitar qualquer alteração não autorizada no arquivo.
- Clique em Iniciar, clique em Executar, digite regsvr32 <path>\VB6IDEMouseWheelAddin.dll e clique em OK (Figura 1).
- Inicie o Visual Basic 6.0.
- Clique em Add-ins e, em seguida, clique em Add-in Manager (Figura 2).
- Na lista Add-in Manager, clique em MouseWheel Fix.
- Clique para selecionar a caixa de seleção Loaded/Unloaded e clique para selecionar a caixa de seleção Load on Startup (Figura 3).
- Clique em OK.
sexta-feira, 28 de janeiro de 2011
Visual basic 6 Secrets
<iframe frameborder="0" scrolling="no" style="border:0px" src="http://books.google.com.br/books?id=kVqB5hjNsScC&lpg=PA839&ots=17_Bru_PXJ&dq=como%20incluir%20unistall%20package%20vb6&pg=PP1&output=embed" width=500 height=500></iframe>
sexta-feira, 10 de dezembro de 2010
Alterar cor ToolBar
With this code you can change a Toolbar backcolor (Windows Common Controls 5 or 6).
You can also use a picture (bitmap) as background, here I'll do both things.
I recommend downloading the example attached, but I'll also show the code here, I used Common Controls 6 toolbars for this example, minor changes are needed if you want to use Common Controls 5 toolbars.
IN THE FORM
- Add 2 Toolbars, change Toolbar1 style to FLAT, Toolbar2 style must remain STANDARD
- Add a Picture box and add a picture to it.
- Paste this code:
VB Code:
| Option Explicit Private Sub Form_Load() Private Sub ApplyChanges() |
IN A MODULE
VB Code:
|
Option Explicit Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _ ByVal hWnd1 As Long, ByVal hWnd2 As Long, _ ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" ( _ ByVal hwnd As Long, ByVal nindex As Long, ByVal dwnewlong As Long) As Long Public Declare Function InvalidateRect Lib "user32" _ (ByVal hwnd As Long, lpRect As Long, ByVal bErase As Long) As Long Public Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long Public Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long Public Enum enuTBType enuTB_FLAT = 1 enuTB_STANDARD = 2 End Enum Private Const GCL_HBRBACKGROUND = (-10) Public Sub ChangeTBBack(TB As Object, PNewBack As Long, pType As enuTBType) Dim lTBWnd As Long Select Case pType Case enuTB_FLAT 'FLAT Button Style Toolbar 'Apply directly to TB Hwnd DeleteObject SetClassLong(TB.hwnd, GCL_HBRBACKGROUND, PNewBack) Case enuTB_STANDARD 'STANDARD Button Style Toolbar lTBWnd = FindWindowEx(TB.hwnd, 0, "msvb_lib_toolbar", vbNullString) 'Find Hwnd first DeleteObject SetClassLong(lTBWnd, GCL_HBRBACKGROUND, PNewBack) 'Set new Back End Select End Sub '==========================================================================' If you want to use Win Common Control 5 Toolbars, use "ToolbarWindow32" instead of ' "msvb_lib_toolbar". Win Common Control 5 Toolbars can't be FLAT, they are always STANDARD, ' so use enuTB_STANDARD when you call this '========================================================================== |
More info about this
- This will also work with xp styles (manifest file).
- If the picture is smaller than the toolbar the pattern will be repeated, if its too big, you will see just part of it, so I recomend to make your bmp or jpg picture the same size of the toolbar. You can also let it repeat the pattern as I did in the project attached.
- Changes will remain visible in design mode until you close VB IDE.
- If you apply this to a toolbar in your app with a given style (i.e: Flat) all the flat toolbars and the controls that contain flat toolbars with the same Comon Controls version will also be modified, (but JUST inside your app).
Example: Common Dialog Control uses a vertical toolbar (WCC version 5).