Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all 1514 articles
Browse latest View live

vbrichclient5.dll examples

$
0
0
hi. very interested to find out where to go to see active discussions on using vbrichclient5.dll.
I have see some posted here but wondered if there was something like planetsourcecode
where users etc can upload code examples of how to do stuff.

I know there is http://www.vbrichclient.com/#/en/About/ but dont see any easy to follow
code examples. ie step by step.

I have searched the internet and only real resource is this site.
many thanks in advance.

k_zeon

URL Save

$
0
0
A program I written a while back, which can save all the important (and not :) ) URL's.

Especially needed to have these URL's at hand when re-installing windows, moving to a new pc or for whatever reason.

Simple code. Straight forward. Nothing special. It's all about the idea.

Included RTF help.

Name:  Image 081.jpg
Views: 54
Size:  25.5 KB

The Program:
URL Save.zip
Attached Images
 
Attached Files

W10 Accounts

$
0
0
When we grow older we tend to forget passwords and user names etc.

Not entirely true. In this day and age, when roaming the internet and became part and participate within the w.w.w. , we create so many different accounts, passwords etc. we WILL forget some of the less-used passwords and/or accounts.

Some users use programs that store these info for them, but are you sure some info is not send when on-line with such so-and-so-password-storer program?

This was the solution to my own security problems.
A program originally written for "Need for speed world" accounts (which I have a lot of :) ), and later it become part of my everyday internet life:

W10 Accounts:
Name:  Image 082.jpg
Views: 80
Size:  24.6 KB

The program:
W10 Accounts.zip
Attached Images
 
Attached Files

[VB6, Vista] List the Recycle Bin location(s) on a drive

$
0
0

Hard coded paths aren't the best system, since they change from Windows version to version. So AAraya was asking about how to do this, and after seeing a StackOverflow and OldNewThing post about using IPersist to get the class ID of a folder, I wrote this in response. The code guarantees that the locations returned are the current, official system bin locations. Note that, especially on non-system drives, a Recycle Bin location may only exist when there are files in it, so if you don't get any results it doesn't mean that there won't be the next time you delete a file on that drive.

Main Code

This project wraps a single main function, FindRecycleBinsOnDrive:

Code:

Private Declare Function ILCreateFromPathW Lib "shell32" (ByVal pwszPath As Long) As Long
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal PV As Long) ' Frees memory allocated by the shell
Private Declare Function SysReAllocString Lib "oleaut32.dll" (ByVal pBSTR As Long, Optional ByVal pszStrPtr As Long) As Long
Private Declare Function SHCreateItemFromParsingName Lib "shell32" (ByVal pszPath As Long, pbc As Any, riid As UUID, ppv As Any) As Long

Private Function FindRecycleBinsOnDrive(sDrive As String) As String()
Dim pItem As IShellItem
Dim penum1 As IEnumShellItems, penum2 As IEnumShellItems
Dim pChild As IShellItem, pChild2 As IShellItem
Dim lpPath As Long, sPath As String
Dim sParent As String
Dim n As Long
Dim pcl As Long, pcl2 As Long
Dim gid As oleexp.UUID
Dim pPersist As oleexp.IPersist
Dim lAtr As SFGAO_Flags
Dim sOut() As String
ReDim sOut(0)

Call SHCreateItemFromParsingName(StrPtr(sDrive), ByVal 0&, IID_IShellItem, pItem)

If (pItem Is Nothing) = False Then
  pItem.BindToHandler ByVal 0&, BHID_EnumItems, IID_IEnumShellItems, penum1
  Do While penum1.Next(1&, pChild, pcl) = S_OK
        pChild.GetAttributes SFGAO_FOLDER Or SFGAO_HIDDEN Or SFGAO_SYSTEM, lAtr
        If ((lAtr And SFGAO_FOLDER) = SFGAO_FOLDER) And ((lAtr And SFGAO_HIDDEN) = SFGAO_HIDDEN) And ((lAtr And SFGAO_SYSTEM) = SFGAO_SYSTEM) Then
            pChild.BindToHandler ByVal 0&, BHID_EnumItems, IID_IEnumShellItems, penum2
            Do While penum2.Next(1&, pChild2, pcl2) = S_OK
                pChild2.BindToHandler ByVal 0&, BHID_SFObject, IID_IPersist, pPersist
                If (pPersist Is Nothing) = False Then
                  pPersist.GetClassID gid
                  pChild2.GetDisplayName SIGDN_DESKTOPABSOLUTEPARSING, lpPath
                  If IsEqualGUID(gid, CLSID_RecycleBin) Then
                      pChild2.GetDisplayName SIGDN_FILESYSPATH, lpPath
                      ReDim Preserve sOut(n)
                      sOut(n) = LPWSTRtoStr(lpPath)
                      n = n + 1
                  End If
                End If
            Loop
        End If
    Loop
Else
    Debug.Print "Failed to get drive object"
End If

FindRecycleBinsOnDrive = sOut
End Function

Private Function CLSID_RecycleBin() As UUID
'{645ff040-5081-101b-9f08-00aa002f954e}
Static iid As UUID
 If (iid.Data1 = 0) Then Call DEFINE_UUID(iid, &H645FF040, CInt(&H5081), CInt(&H101B), &H9F, &H8, &H0, &HAA, &H0, &H2F, &H95, &H4E)
 CLSID_RecycleBin = iid
End Function

Private Function LPWSTRtoStr(lPtr As Long, Optional ByVal fFree As Boolean = True) As String
SysReAllocString VarPtr(LPWSTRtoStr), lPtr
If fFree Then
    Call CoTaskMemFree(lPtr)
End If
End Function

The code increases efficiency by only examining folders that have the properties of the Recycle Bin, a folder with the Hidden and System attributes.

Alternative Method

I had also written a different method to get the top level bin names. This method uses the KnownFolderManager class to enumerate (just the first level of) files in the Recycle Bin virtual object (which includes all the physical locations on different drives), and then get the top level bin folders of all drives at once:

Code:

Private Sub EnumRecycleBinPaths(sBinPaths() As String)
Dim kfm As New KnownFolderManager
Dim pk As IKnownFolder
Dim pItem As IShellItem
Dim penum1 As IEnumShellItems
Dim pChild As IShellItem
Dim lpPath As Long, sPath As String
Dim sParent As String
Dim n As Long
Dim pcl As Long

ReDim sBinPaths(0)
kfm.GetFolder FOLDERID_RecycleBinFolder, pk
If (pk Is Nothing) = False Then
  pk.GetShellItem KF_FLAG_DEFAULT, IID_IShellItem, pItem
  pItem.BindToHandler ByVal 0&, BHID_EnumItems, IID_IEnumShellItems, penum1
  Do While penum1.Next(1&, pChild, pcl) = S_OK
        pChild.GetDisplayName SIGDN_FILESYSPATH, lpPath
        sPath = LPWSTRtoStr(lpPath)
        sParent = Left$(sPath, 3)
        sPath = Mid$(sPath, 4)
        sParent = sParent & Left$(sPath, InStr(sPath, "\"))
        arr_add_dedupe sBinPaths, sParent
    Loop
End If

End Sub
Private Sub arr_add_dedupe(sAr() As String, sNew As String)
Dim i As Long
For i = 0 To UBound(sAr)
    If sAr(i) = sNew Then Exit Sub
Next
Debug.Print "New entry=" & sNew
If (UBound(sAr) = 0) And (sAr(0) = "") Then
    sAr(0) = sNew
Else
    ReDim Preserve sAr(UBound(sAr) + 1)
    sAr(UBound(sAr)) = sNew
End If
End Sub

This method is simpler, but might be slower if you have tens of thousands of items in the root of your recycle bin (like Plex does).

Requirements
-Windows Vista or newer (you can get to IPersist while enumerating with IShellFolder, if you really needed to do this on XP)
-oleexp.tlb v4.0 or higher
-oleexp AddOn mIID.bas (included in oleexp download)
Attached Files

VB6 - JACMail V3

$
0
0
JACMail Version 3.0 is very similar to previous Versions. I have abandoned attempts to add encryption to Email service, as TLS 1.0/1.1 is no longer supported on many servers. TLS 1.2 supports ECC (Elliptical Curve Cryptography), which is what I want to use because it avoids having to store keys. Unfortunately I have not yet found a way to recover the Raw Agreed Secret to support TLS 1.2 using CNG. The current Email standards are ancient and difficult to work with. It does not easily support encryption or non-latin character sets, and the lack of authentication allows the proliferation of unsolicited email and malware. Because of the large installed base of MTAs, previous attempts to upgrade it have failed. Therefore, I have removed encryption from JACMail, and I am currently concentrating on a private email service using ECC and authentication. JACMail V3 uses SimpleSock, which makes it faster.

JACMail is an Email Client Program designed to allow fast and efficient recovery of email from a POP3 server, and the sending of email through an SMTP server. It is primarily oriented towards text based messaging with attachments, and does not directly support highly formatted HTML based email or embedded objects. It receives and stores both text/plain and text/html messages, and Web based emails (HTML) can be sent to your default browser for viewing. It also supports Plain Authentication based POP3 and multiple mailboxes. The mailboxes are stored in an Access database utilizing ODBC.

The code uses IP Version independent system calls, so it will only work on Windows systems that actively support both IPv4 and IPv6. That more or less restricts it to Windows Vista or later. It has been tested on Windows Vista, Win 7, Win 8.1, and Win 10, and utilizes the following standard components and references:
RICHED32.DLL
RICHTX32.OCX
COMDLG32.OCX
MSSTDFMT.DLL
MSBIND.DLL
MSADODC.OCX
MSDATGRD.OCX
which the user must have available in order to compile the program.

J.A. Coutts
Attached Images
 
Attached Files

[VB6, Vista+] Enumerate, explore, and change all file associations

$
0
0

File Associations

This program is similar to the Default Programs control panel applet. It scans the registry for all registered file extensions, then uses the AssocCreate API and IQueryAssociations interface to get further information. The icons are then loaded through SHGetFileInfo and added to the ListView. There's several methods to change the associations-- through the IAssocHandler interface, that lists the recommended programs you see in the Open With dialog; just click a program on the menu and it becomes the new default, updating Windows, next there's the Open With dialog, SHOpenWithDialog, which you can call passing only a file extension to change the default for all files of that type. However, this functionality is no longer available on Windows 10, because MS just loves taking away user control of the OS: you *have* to use the Control Panel to do it on Windows 10, so using the IOpenControlPanel interface we can at least send the user straight to the correct page. Note that this works on Vista/7/8 too; it's just that on Win10 it's the only way, but you can open that control panel page on earlier systems too.

AssocCreate

This function requires quite a bit of effort to be called through VB. It was declared in the original olelib, but that declare will not work (I'll fix it in a future version, but for now it has to be declared in a module). The CLSID parameter *must* be ByVal, but you can't send a user type ByVal. This even though the RIID parameter, which uses the same type (a GUID), *can* be passed ByRef. Passing VarPtr is not accepted, so the natural alternative is to pass each member of the struct ByVal. However, that still doesn't work, you get a "Bad DLL Calling Convention" error. The only way to do this is to rearrange a GUID, Long-Int-Int-Byte x8, into 4 Longs. Doing it this way works, and the interface is created:

Code:

Public Declare Function AssocCreate Lib "shlwapi" (ByVal CLSIDd1 As Long, ByVal CLSIDd23 As Long, _
                                                ByVal CLSIDd40123 As Long, ByVal CLSIDd44567 As Long, riid As UUID, ppv As Any) As Long


Dim pQA As IQueryAssociations
Dim lData1 As Long
Dim lData23 As Long
Dim lData40123 As Long
Dim lData44567 As Long
Dim ab() As Byte
ReDim ab(15)
Dim tCLSID As UUID
tCLSID = CLSID_QueryAssociations
CopyMemory ab(0), tCLSID, 16&
CopyMemory lData1, ab(0), 4& '0 1 2 3
CopyMemory lData23, ab(4), 4& '4 5 6 7
CopyMemory lData40123, ab(8), 4& '8 9 10 11
CopyMemory lData44567, ab(12), 4& '12 13 14 15
AssocCreate lData1, lData23, lData40123, lData44567, IID_IQueryAssociations, pQA

From there we can proceed to call whatever we need.
Code:

    pQA.Init 0&, sExt, 0&, Me.hwnd
    pQA.GetString 0&, ASSOCSTR_FRIENDLYDOCNAME, sVerb, sBuf, lp

and so on.

Some types appear in the registry but actually don't have handlers, so an error is thrown and it won't appear in the list. Another issue is with certain media files that have 'Play' as their default verb. Even Windows itself doesn't handle this properly, so we do the best we can. It will show the icon and the description, but like the control panel will say 'Unknown application' for opening it, even though the Play verb is being used and it works when you double click it.

The menu with the other default program choices you might recognize as mostly the code from my first project about file associations, [VB6] List/Execute File Handlers: IAssocHandler and IAssocHandlerInvoker (Vista+). Generating that menu adds quite a bit of code, but it's all just from that first project, and can be easily cut out by simply removing the GenerateOpenWithMenu submenu.

Finally, as a bonus, this project includes a new modular definitions BAS, for menus. I got tired of having to sift through which declares were needed, so like other controls menus now have a drop-in module that covers it all. The ListView/Header and ImageList modular definitions are also used.

Requirements
-Windows Vista or newer
-oleexp.tlb v4.0 or higher (only needed for the IDE, it gets compiled into your exe)
-oleexp addon mIID.bas (included in the oleexp download)
Attached Files

VB6 - Program Communication

$
0
0
There are numerous examples of SendMessage useage, and this is my version of communication between 2 programs. The basics came from "www.TheScarms.com", and were adapted to provide a way to issue instructions from one program to another, and pass the results back. The use of a data structure
Code:

Private Type COPYDATASTRUCT
    dwData As Long  ' Use this to identify your message
    cbData As Long  ' Number of bytes to be transferred
    lpData As Long  ' Address of data
End Type

provides the ability to identify different types of messages. In this example, I have used the type identifier to distinguish between integer, long, and string variables, but it could be used to identify anything.

J.A. Coutts
Attached Files

Open files in vb5

$
0
0
Hi
I have multiple word and excel 2007 files on desktop in a folder and would like to view them in a list box and subsequently open any of the file through button after selected.
Two problems are coming up:
1----- Doc and xls files are not coming in List box together; only doc files are visible?
2----- After selecting file in List box and pressing button an error message pop up Run time error 424 and beneath it "Object Required".
below link

https://1drv.ms/f/s!ApB75VvFFQtogTE9mIiVnpcql4Li

is for the files to view coding.

regards

AM

Add a little Pizazz to Your Menus & Toolbar Dropdowns

$
0
0
Here's a project to add Menu Bitmaps and Toolbar Dropdown bitmaps.
I have included a companion project to create menu bitmaps (14x14) from
other graphic file types and icons (24 bit & lower)

Enjoy.


Name:  ScreenShot.JPG
Views: 133
Size:  12.8 KB
Attached Images
 
Attached Files

VB6 - Heart Beat

$
0
0
There are many reasons that a TCP connection can be lost, not the least of which is the NAT router that it might sit behind. In my ongoing efforts to develop a private mail system, I needed to know if a client was still connected to the server. There was also a need to provide for a Client to connect to the server when it becomes available. So I developed a Heart Beat system.

This is a dual purpose system. In the examples I have provided, the Client includes a timer that is set to activate every 5 time slots. Normally the time slot would be 60 seconds (1 minute), but for testing I reduced it to 10 seconds. If the client is not currently connected to the server, it will attempt to connect. If it is already connected to the server, then it sends a Heart Beat packet to signal to the server that it is still alive and connected.

The server in essence ignores the packet, except that it increments a counter. The server also contains a timer, but this one activates every 10 time slots. If the Client has not sent any traffic in the last 10 time slots, the counter is zero and it is disconnected.

J.A. Coutts
Attached Files

VB6 Flickr API - Open To Everyone

$
0
0
Hi all dear fellows VB6 Programmers,

A bit of introduction:
Sometime ago, I ventured to develop a module to my Document Management System.
With this module I could manage my own photographs, by indexing my own data fields, storing (in a structured local folders), adding Keywords(Tags) from about 1M ISO standardized keywords tree, adding geolocation (Google Maps Integration), saving IPCT/Exif (exiftool) Copyright and Data into image file, uploading the image to Flickr, keeping track of views, faves, comments and my photos chosen to be featured in the Flickr Explorer and/or galleries, and lastly keeping a backup of it all locally and in the cloud. Also, I wanted to manage my Flickr contacts’ photos updates, photos I’ve viewed, skipped or faved/commented.
At that point in time, I did a strenuous research into flickr’s API but ended up without any reference material for VB6, the only one reference I found was a Flickr’s group which seemed to be dead since 2008 (I think), apart from that I could not find anything to start from, and my last resource was using the browser-control to collect/process the data I required for doing all this stuff. A couple of weeks ago I started a thread in this forum asking for help to solve an issue, what leaded me to another thread from another user; When user Olaf Schmidt came up with one solution that would open the possibility to me to use the proper Flickr’s API rather than using “Tricks” to collect data. Anyway, the only one bad side, Olaf was proposing to use his proprietary Library, what I did not like.

Since then, I’m working in this class module that allows me to use Flickr’s API without any external 3rd party libraries. So, my idea is to share with who might be interested. This thread is open to anyone who want to participate sharing and helping in this little task.
The following code is free to you use as you will, but I hope that if you learn something new you come back and share with us.

This is the version 0 and cover only 3 flickr’s methods, but soon, I hope, we will cover all Flickr’s API methods.

Is there any VB6 developer who also love photography and has it as a hobby (or alternative business?)?

So, here we go,

Thanks to all you guys who replied to my threads, posted positive comments and helped me to take this step.

Thanks for any feedbacks, critiques and suggestions.
MBS.


Code:

'*******************************
'PROJECT REFERENCES: MICROSOFT XML 6.0 (msxml6.dll)
'*******************************

'*******************************
' DECLARATIONS
Public c_FlickrAPI As New Flickr_API_Class
Public flickr_APIkey As String

Public xXML As New MSXML2.DOMDocument
Public xXML_Parsed As New MSXML2.DOMDocument
Public xml_Nodes As MSXML2.IXMLDOMNodeList
Public xml_Node As MSXML2.IXMLDOMNode

Private Sub Form_Load()

    flickr_APIkey = "6a669c22eae9c3cc0c4bc67a26f2b1ce"
    ' YOU WILL NEED YOUR OWN APIKEY
    ' OR USE A TEMPORAY KEY LIKE THE ONE ABOVE, THESE TEST APIKEY ONLY WORKS UNTIL 23:59h OF THE DAY YOU ACQUIRED IT
    ' TO GET A TEMPORAY APIKEY
    ' 1 - GO TO: https://www.flickr.com/services/api/explore/flickr.test.echo
    ' 2 - CHECK THE OPTION: [Sign call with no user token?]
    ' 3 - HIT [CALL METHOD]
    ' 4 - RETRIEVE THE APIKEY FROM THE RESPONSE
    '<api_key>6a669c22eae9c3cc0c4bc67a26f2b1ce</api_key>

    FlickerExplorer
   
End Sub

Private Sub FlickerExplorer()

    ' BASICLY CALLING THE FLICKR API FUNCTIONS / METHODS ARE ALL THE SAME, FIND NEXT HOW TO
   
    ' CALLING THE flickr_Explorer_GetPhotos from FLICKR APIs

    xXML.loadXML c_FlickrAPI.flickr_Explorer_GetPhotos()
    Set xml_Nodes = xXML.SelectNodes("/methodResponse/params/param/value/string")
   
    If xml_Nodes Is Nothing Then Stop ' DID NOT GET THE NODES PROPERLY
    If InStr(1, xXML.Text, "faultCode") <> 0 Then Stop ' SOMETHING ELSE WENT WRONG
   
    ' THE XML-RPC STORE THE XML DATA INTO A [escaped-xml-payload] WITHIN THE [string] NODE
    ' SO WE GET THE FULL XML TO PARSE THE ROOT NODES AND THEN LOADXML FROM THE XML.TEXT,
    ' TO GET THE PARSED XML WITH PHOTOS NODES.
    '
    ' OF COURSE YOU CAN CODE A FUNCTION/SUB TO DO IT, I DID NOT DO IT YET, BECAUSE I'M TOO LAZY LOL
    ' THE XML-RPC STRUCTURE CAN BE FOUND HERE: https://www.flickr.com/services/api/response.xmlrpc.html

    xXML_Parsed.loadXML xml_Nodes.Item(0).Text
    Set xml_Nodes = xXML_Parsed.SelectNodes("/photos/photo")
   
    If xml_Nodes Is Nothing Then Stop ' DID NOT GET THE NODES PROPERLY
    If InStr(1, xXML.Text, "faultCode") <> 0 Then Stop ' SOMETHING ELSE WENT WRONG
   
    For Each xml_Node In xml_Nodes
       
        ' TO GET ITEMS DATA JUST CALL xml_Node.SelectSingleNode AS FOLLOW
       
        vm_PHOTOID = xml_Node.SelectSingleNode("@id").Text ' PHOTO/ITEM ID
        If Not IsNumeric(vm_PHOTOID) Then Stop 'SOMETHING WENT WRONG
       
        vm_UserID = xml_Node.SelectSingleNode("@owner").Text ' ITEM USER OWNER
        If InStr(1, vm_UserID, "@") = 0 Then Stop  'SOMETHING WENT WRONG
       
        vm_URLtIMG = xml_Node.SelectSingleNode("@url_t").Text 'ITEM THUMBNAIL URL

        vm_TITIMG = xml_Node.SelectSingleNode("@title").Text 'ITEM TITLE
       
    Next
End Sub

Code:

'*************************************************
' FLICKR API LIBRARY: NAME: Flickr_API_Class
' BY: MBS - ON: 27/09/2017
' LICENSE: DO WHATEVER YOU WANT TO IT, AT YOUR OWN RISK ;-)
'
' THANKS TO: OLAF SCHMIDT
'*************************************************
' V.0 - 27/09/2017
' THREE FUNCTIONS AKA FLICKR METHODS:
' flickr_People_GetPhotos          =  .people.getPhotos                  = Return photos from the given user's photostream
' flickr_Explorer_GetPhotos        =  .interestingness.getList            = Returns the list of interesting photos (AKA EXPLORER) for the most recent day or a user-specified date
' flickr_GetListRecentlyUploaded    =  .contacts.getListRecentlyUploaded  = Return a list of contacts for a user who have recently uploaded photos
'
' AND I'M WORKING ON THE NEW OAUTH AUTHENTICATION METHODS (A SERIE OF OTHER API METHODS REQUIRE AUTHENTICATION)
' IF YOU HAVE ALREADY WALKED ON THIS LANDS, YOU ARE MOST WELCOME TO JOIN AND SHARE
' FLICKR/OATH AUTHENTICATION DOCUMENTATION: https://www.flickr.com/services/api/auth.oauth.html

Option Explicit

Public flickr_APIkey As String 'I WOULD SUGGEST YOU TO DECLARE flickr_APIkey IN YOUR GENERAL DECLARATIONS MODULE "MODULE1.BAS"

Public Function flickr_People_GetPhotos(p_UserNSID, Optional p_per_page As Long = 500, Optional p_page As Long = 1, Optional p_extras As String = "url_o,url_k,url_h,url_b,url_c,url_z,url_m,url_t") As String
  ' I WILL COMMENT ONLY THIS FUNCTION, EVERY OTHER HAS BASICLY THE SAME PARAMETERS AND FUNCTIONALITY
  ' FOR MORE DETAILS ON EACH METHOD GO TO: https://www.flickr.com/services/api/
  '
  ' p_UserNSID = REQUIRED, FLICKR USER NSID TO GET ITEMS (TO FIND DOCUMENTATION FOR USERNSID: https://www.flickr.com/services/api)
  ' p_per_page = OPTIONAL, NUMBER OF ITEMS (PHOTOS,VIDEOS ETC) RETURNED IN ONE PAGE, THE DEFAULT IS 500 ITEMS AND ALSO IT'S THE MAXIMUM VALUE PER PAGE
  ' p_page = OPTIONAL, PAGE NUMBER TO GET ITEMS (IF USER HAS 500+ ITEMS, IT WILL BREAK IN TWO OR MORE PAGES (500 ITEM PER PAGE) / DEFAULT = 1
  ' p_extras = OPTIONAL, RETURN THE URL FOR THE MOST COMMON IMAGES SIZES, THE DEFAULT IS WHAT I USE MOST, BUT YOU CAN CHANGE IT AT YOUR WILL.
  ' I SUPRESSED A FEW PARAMENTERS IN THIS FUNCTION, PARAMETER THAT I NEVER USE, BUT IF YOU WAT TO ADD ANY OTHER JUST FIND FULL DOCMENTATION IN
  ' FLICKR METHOD AND ARGUMENTS PAGE: https://www.flickr.com/services/api/...getPhotos.html
 
  ' THE FOLLOWING CALL USES THE NATIVE WinHttpRequest object TO EXECUTE FLICKR API METHOD
  '
  ' THE RESPONSE FORMAT format=xmlrpc - CAN BE CHANGED: FLICKR AVAILABLE RESPONSE FORMATS ARE: REST, XML-RPC, SOAP, JASON and PHP
  ' I'VE CHOOSE XML BECAUSE I CAN USE NATIVE (MICROSOFT) XML OBJECTS/PARSER NOT REQUIRING ANY EXTERNAL PARSER
  ' IF YOU WANT YOU CAN CHANGE THE RESPONSE FORMAT AND WORK AS YOU WILL, FOR DOCMENTATION FOR RESPONSE FORMATS: https://www.flickr.com/services/api/
 
  With CreateObject("WinHttp.WinHttpRequest.5.1")
      .Open "GET", "https://api.flickr.com/services/rest/?format=xmlrpc&method=flickr.people.getPhotos" & _
            "&api_key=" & flickr_APIkey & _
            "&user_id=" & p_UserNSID & _
            "&extras=" & p_extras & _
            "&per_page=" & p_per_page & _
            "&page=" & p_page, False
      .send
      If .Status = 200 Then flickr_People_GetPhotos = .responseText: Exit Function
      ' IF STATUS = 200 = HTTP_STATUS_OK = THEN RETURN FULL XML
     
      flickr_People_GetPhotos = "Fail: " & .StatusText
      ' IF STATUS = ANYTHING ELSE, SOMETHING WENT WRONG, YOU CAN CRITIQUE THE FAIL ERRORS CODE IF YOU WANT.
      ' FIND STATUS CODE HERE: https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
     
  End With
 
End Function

Public Function flickr_Explorer_GetPhotos(Optional p_per_page As Long = 500, Optional p_page As Long = 1, Optional p_extras As String = "url_o,url_k,url_h,url_b,url_c,url_z,url_m,url_t") As String
 
  With CreateObject("WinHttp.WinHttpRequest.5.1")
      .Open "GET", "https://api.flickr.com/services/rest/?format=xmlrpc&method=flickr.interestingness.getList" & _
            "&api_key=" & flickr_APIkey & _
            "&extras=" & p_extras & _
            "&per_page=" & p_per_page & _
            "&page=" & p_page, False
      .send
      If .Status = 200 Then flickr_Explorer_GetPhotos = .responseText: Exit Function
      flickr_Explorer_GetPhotos = "Fail: " & .StatusText
  End With
 
End Function

Public Function flickr_GetListRecentlyUploaded(p_date_lastupload As Long, Optional p_filter As String = "all") As String
 
  With CreateObject("WinHttp.WinHttpRequest.5.1")
      .Open "GET", "https://api.flickr.com/services/rest/?format=xmlrpc&method=flickr.contacts.getListRecentlyUploaded" & _
            "&api_key=" & flickr_APIkey & _
            "&date_lastupload=" & p_date_lastupload & _
            "&filter=" & p_filter & "&auth_token=72157687241136323-f465a033e87d8d0f", False
                                    'YOU HAVE TO GET A NEW auth_token ON EVERY SINGLE CALL
      .send
      If .Status = 200 Then flickr_GetListRecentlyUploaded = .responseText: Exit Function
      flickr_GetListRecentlyUploaded = "Fail: " & .StatusText
  End With

End Function

PS: I DON'T KNOW WHY MY CODE FORMAT DOESN'T GET COLOURS AS I'VE SEEN IN ANOTHER POSTS?

[vb6] Overcoming LoadResPicture (ICON/CURSOR) Limitations in IDE

$
0
0
I doubt many are unaware, but some probably are. So let me start by stating the limitations of using LoadResPicture with the vbResIcon and vbResCursor options while in the IDE.

1. Cannot specify the size of the loaded icon. Always loaded as default (32x32 in 100% DPI)
2. Icons/cursors having color depths other than the screen will not be used. Assumes more than one bit depth is provided in the icon resource.
3. Cursors are always loaded as default size
4. Cursors are loaded black and white in IDE, but color when compiled.

By using a couple of APIs to find and load a specified icon/cursor, we can force VB to use the size we want. Problems number 1, 2 and 4 above are overcome by this method. Problem number 3 remains but, typically, is expected behavior.

Here are a couple scenarios regarding icons.

Scenario 1: You have an icon file containing only a 128x128 image. If you add that icon, in design, to a VB picture property, you get a 128x128 icon. But if you add it to your resource file then use LoadResPicture(##, vbResIcon), what you get is a scaled-down 32x32 icon.

Scenario 2: You have an icon file with multiple images of varying sizes and color/bit depths. If you add that icon to a VB picture property, you get the first image in the file and cannot choose a size or color depth. If you add the icon file to a resource file, you get a 32x32 icon if it exists, else the same behavior as noted above.

By using a couple of APIs, we can ask Windows to select the icon size we want when the icon file, added to a resource file, contains multiple sized images. Even if we wanted a size not in the file, we can ask that it be scaled for us. This method works whether compiled or not.

Caveats...
1. Though the code will load a 32bpp icon (XP+) and those containing PNG compression (Vista+), VB still may not display it correctly. These types of icons may fail if loaded directly via the resource editor. Adding these types of icons may require alternate tools like the Microsoft RC.exe application. Icons larger than 255x255 may also require such tools.

2. If you have an icon resource that contains multiple images of varying sizes and depths, it is assumed that for each size, you have the same number of icons per depth. For example, if having icon sizes of 16, 32, 48 and depths of 8 and 32 bits, it is expected you have 6 icons, an 8 and 32 bit version for each size. This assumption is a requirement if you use the code's option to select an icon of a specific color depth. After all, this is your project and you dictate what gets added to the resource file and what doesn't. Therefore, you shouldn't be asking for a color depth that doesn't exist.

3. If you have icons of sizes 256x256 and 512x512, they are likely PNG compressed. However, when asking for one of those, the 1st one in the icon file will be used and scaled as needed. This is because the APIs being used cannot distinguish between icon sizes larger than 255x255. This can be worked around and will consider it if wanted. The Vista API mentioned below may not have that problem but not tested it and it is not compatible with uncompiled projects.

FYI... LoadIconWithScaleDown is a newer API function that requires at least Vista and also cannot be used unless project is compiled. That function allows you to do what this code does but, again, not while uncompiled. That API also works with icon files on disc.

Post# 2 has the code. The zip below has a sample project with methods included.
Attached Files

ID a MSChart Piechart slice with MouseMove

$
0
0
Have you ever wanted to ID a "slice"of a MSChart PieChart by simply moving the mouse over it?

Well, here is a possible way to do so using a ToolTip.

Code:

Dim sX()

Private Sub Command1_Click()
    '
    With Command1
        .Top = 800
        .Left = 500
    End With
    With MSChart1
        .Top = 500
        .Left = 2000
        .Height = 3500
        .Width = 3000
        .Visible = True
        '
        ReDim sX(1 To 4)
        sX(1) = 1.25
        sX(2) = 2.25
        sX(3) = 3.25
        sX(4) = 5.25
        '
        .ChartData = sX
        .ChartType = VtChChartType2dPie
        .Title = "Totals Split by Acct"
        '
        .Column = 1
        .ColumnLabel = "Acct 1"
        .Column = 2
        .ColumnLabel = "Acct 2"
        .Column = 3
        .ColumnLabel = "Acct 3"
        .Column = 4
        .ColumnLabel = "Acct 4"
    End With
    '
End Sub

Private Sub MSChart1_Mousemove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    '
    Dim Part As Integer
    Dim Series As Integer
    Dim DataPoint As Integer
    Dim Index3 As Integer
    Dim Index4 As Integer
    '
    '
    With MSChart1
        .TwipsToChartPart X, Y, Part, Series, DataPoint, Index3, Index4
        If Series > 0 Then
            .Column = Series
            txt = .ColumnLabel
            .ToolTipText = txt & " ... " & sX(Series)
        End If
    End With
    '
End Sub

Here is a screenshot

Name:  MSChartCB1.png
Views: 28
Size:  6.3 KB

Unfortunately, my use of Paint did not grab the mouse pointer.
However, it is in the blue slice.

Comments
  1. Truth be told, I had not used a PieChart, let alone a MSChart before encountering this thread
  2. Credit is due to starscrea2 for the basics
  3. Credit is due to chosk for pointing out the TwipsToChartPart Method
  4. Credit is due to DEXWERX for suggesting the CodeBank location.


HTH

EDIT-1

I noticed that if the mouse is over the control (within the border but not on a slice)
  • I got a Tooltip for Series 0
  • so I added the test If Series > 0 Then



Spoo
Attached Images
 

[VB6] ucShellBrowse: A modern replacement for Drive/FileList w/ extensive features

$
0
0


ucShellBrowse v1.0

About
This project started its life as an attempt to select a file right on a Property Page without having to click an additional button. There's still a lot of outstanding issues severely limiting the practicality, usability, and stability of that version, so pending further development on that I continued to make a UserControl version. This is basically having an updated, prettier version of VB's DirList/FileListBox, with further options that allow it to have the power of an actual Explorer window-- but doing it with a ComboBoxEx and ListView allow for customizations and features not possible if you were to simply host an instance of Explorer itself instead. It integrates many of the techniques my small sample projects have shown over the past few years.

Key Features
  • Full Unicode support
  • Icons, display names, and properties are identical to what a user sees in Explorer. Includes overlay icons for things like shares or links; supports custom ones like used by DropBox or Github.
  • Full navigation tree from the desktop-- virtual objects that are part of the file system, such as Computer or Libraries, are able to be used normally, and the selections real file system path is resolved and returned.
  • Support for several different view modes: Large icon, small icon, list, details, tiles, and thumbnails.
  • Thumbnail View uses the code from my ThumbsEx project, which goes beyond what Explorer can do by using GDI+ to center and frame images smaller than the thumbnail size. The thumbnail size can be set to any value.
  • Optional setting to enable extended thumbnails, like video files showing the first frame.
  • Images and all types with a registered preview handler can be previewed in an optional preview pane.
  • 'Group by' is fully implemented; can group for extended properties
  • Right click brings up the standard shell context menu
  • Sort is supported for all columns and uses the same API that is used by Explorer, so order is identical
  • A filter can be applied to only show files matching a certain type (PathMatchSpecW); an option specifies whether it's single-select or multi-select.
  • Supports rename-in-place with ListView LabelEdit, with blocks and warning popups to prevent disallowed characters. Renames are carried out through Explorer via IFileOperation.
  • Rename, and other functionality, is still supported even if file name extensions are hidden (the ListView uses the Explorer displayname, so if they're hidden in Explorer they're hidden here)
  • Supports 'Create new folder' where a new folder is created, with its name the next in sequence if needed, and a label edit to rename is automatically initiated.
  • Supports both dragging out and receiving dropped files, complete with the file icons you see in Explorer. Drops go through Explorer, meaning 3rd party shell extensions like WinRAR are supported.
  • All column headers found in Explorer are available to be added/removed/sorted by/grouped by, directly interfacing with the Windows Property System and each files Property Store.
  • Default column headers are loaded for each folder from Explorer; so when you browse to your Music library you get Artist, Album, Title, and Track as the columns (this behavior can be disabled)
  • Optional status bar that shows the number of files, their total size, and menu item help. A custom message can also be set.
  • The Back/Up/View control box can be shown or hidden; this combined with option to limit or turn off columns allows for compacting down to the same size as the original VB file browsing controls. ListView icons can even be hidden.
  • There's substantial interaction with the host form, informing your program of selection change, clicks, double clicks/enter press, directory change, renames, and file drops. These events provide both full paths and references to the file(s) IShellItem(Array) interfaces
  • The startup path can be customized and is remembered. The current path can be manually changed through a .BrowserPath property.
  • Custom draw is used to show encrypted files in green and compressed files in blue to be consistent with Explorer (this can also be forced on or forced off)

There's also fairly extensive debug output to the Immediate window. You can stop it from appearing by changing the 2nd line of ucShellBrowse.ctl; Private Const dbg_PrintToImmediate As Boolean = True --Change it to False to stop debug printing.

Requirements
-Windows Vista or newer
-If using this as a .ctl, your project must contain mSBSubclass.bas (from the main folder of the project), or the code from it placed in another .bas, and have a reference to oleexp.tlb v4.3 or higher (released 11 Sep 2017).

To use the control as an OCX, open ShellBrowse.vbp from the main folder, change the UserControl to 'Public', and compile. Then proceed to move, register, and use as you would any other .ocx. A project with the OCX does not require mSBSubclass.bas or oleexp.tlb. For future versions, I'll inquire with the admins about posting a pre-compiled .ocx.

The folder \Demo\ contains Project1.vbp which uses the control as an in-project .ctl.

Future Plans
There are a few advanced features, that aren't critical, that are going to take me a few weeks to finish. But I wanted to put out an initial release in the mean time and see how things go. These include:
-A details bar like the bottom of Explorer windows. This is more complex than one would think since it needs to detect if there's a registered property handler, and if so, load the PreviewDetails, figure out how many can fit in the current bar size, align them, and provide the ability to edit them. There's some debug code commented out that shows some of the techniques involved if you're interested in exploring that on your own before I finish it, in LVDoubleClick.
-Providing dynamic dragover highlighting. So when a user drag a file over from another app, if it's dragged over a folder or a zip file that's displayed in the ListView, that item is highlighted and can be dropped on. I've developed code to do this already, but it's not portable at all so will take a while to add to a new project.
-Registering with SHChangeNotifyRegister to monitor for file/folder changes and update accordingly. Much more complicated than you'd think, especially to keep the folder tree updated as well. There's a Refresh call and a RefreshTree call to manually update things in the mean time.

If there's another feature you'd like to see don't hesitate to suggest it :wave:

This project is complicated and still under development
And I'm doing it for fun in my spare time, so don't expect commercial production grade code. I know basic functionality is working right now, and every feature was working when it was added, but there's almost certainly going to be a few bugs here and there in the 10,000 lines that make up this extensive project. It's simply not possible to test every feature in every scenario it may encounter.
So if you encounter a bug, kindly let me know and I'll get it fixed for the next release.
Since it's still under active development, there's also a lot of commented out debug code left in, and definitions from common control headers that aren't used. This will be cleaned up once it's feature-complete. (It's also a principle of mine, I'm always curious and interested in seeing these kind of things in others code, so I tend to leave it in for my projects in this forum, in case anyone else shares my interest).

Edit: Just to point something out that's a little funny, it's turning out that stupid little details bar is outrageously complex, and by far the most difficult part of this entire project. Just figuring out what properties are supposed to be displayed took 5 coding marathons 6-7 hours long each lol.. Needless to say, this wasn't well documented, and some of the documentation outright contradicted Explorer's actual behavior.
Now that I know which properties to display, all I have to do is generated an array of API-drawn (because unicode) of textboxes, labels aligned to them, in a number of rows/columns that varies during runtime, linked to the properties, and allow editing the ones that can be edited, and save that back to the file. Simple lol :confused:
Attached Files

[vb6]Treeview - Prevent from indenting when no icon is used

$
0
0
Just a neat option. It has its limitations. It works for both versions 5 & 6 of the common controls TreeView.

In the screenshot below, you'll notice that the left image has indentation, or reserved white space for icons, when icons (ImageList) are used and no icon is assigned. Looks kinda ugly. But we can avoid this with a little API help.

Name:  treeIcons.png
Views: 117
Size:  7.2 KB

Limitations:
1. You cannot use any treeview style that includes icons, i.e., not tvwTreeLinesPictureText
2. You cannot use the checkbox style (image above uses icons vs checkbox style)
3. The number of different icons you can use is limited to 15 maximum
4. You must add a bogus icon in the ImageList. This bogus icon is always the 1st one

The reason for 15 max icons is that this API option only allows 4 bits to identify an icon index. With only 4 bits, we have a maximum range of 0 to 15. The value 0 is used to clear the icon, values 1 thru 15 are the possible icons in your image list, starting with the 2nd icon in the list. So, consider the icons in the imagelist as zero-bound even though you can reference them directly as one-bound. Because they are considered zero-bound, and zero index is used to clear the icon, the 1st icon in the image list is simply not used.

Here are the APIs used
Code:

Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Const TV_FIRST As Long = &H1100
Private Const TVM_GETITEMA As Long = (TV_FIRST + 12)
Private Const TVM_SETITEMA As Long = (TV_FIRST + 13)
Private Const TVM_GETNEXTITEM As Long = (TV_FIRST + 10)
Private Const TVM_GETITEMRECT As Long = (TV_FIRST + 4)
Private Const TVM_SETIMAGELIST As Long = (TV_FIRST + 9)
Private Const TVSIL_STATE As Long = 2
Private Const TVIF_STATE As Long = &H8
Private Const TVGN_ROOT As Long = &H0
Private Const TVGN_CHILD As Long = &H4
Private Const TVGN_NEXT As Long = &H1
Private Const TVGN_CARET As Long = &H9

The image list must be assigned via this call. Should be added in Form_Load.
Note that you still associate the ImageList via the Treeview property page, as normal.
Code:

' change Treeview1 & ImageList1 as needed
    SendMessage TreeView1.hWnd, TVM_SETIMAGELIST, TVSIL_STATE, ByVal ImageList1.hImageList

This helper function is used by the other 3 public functions. Purpose is to retrieve the node ID (assigned by the window) not the index/key assigned by the control. It does this by reverse navigating from the target node to the 1st (root) node in the tree.
Edited: See post #2 for an alternate method of retrieving the Node ID
Code:

Private Function pvGetTreeItem(tView As TreeView, Node As Node) As Long

    Dim rNode As Node, tNode As Node
    Dim cMoves As Collection
    Dim c As Long, hItem As Long
   
    If tView.SelectedItem Is Node Then ' quick access
        hItem = SendMessage(tView.hWnd, TVM_GETNEXTITEM, TVGN_CARET, ByVal 0&)
    ElseIf Node Is Node.Root Then ' quick access
        hItem = SendMessage(tView.hWnd, TVM_GETNEXTITEM, TVGN_ROOT, ByVal 0&)
    Else
        Set cMoves = New Collection
       
        Set rNode = Node.Root                  ' used for reference
        Do Until tNode.Parent Is Nothing        ' navigate up the tree from passed node
            Set rNode = tNode.Parent.Child      ' used for reference
            Do Until tNode Is rNode
                cMoves.Add TVGN_NEXT            ' inverse navigate using NEXT
                Set tNode = tNode.Previous
            Loop
            cMoves.Add TVGN_CHILD              ' inverse navigate using CHILD
            Set tNode = tNode.Parent
        Loop
        Set tNode = Node                        ' used for reference
        If Not tNode Is rNode Then              ' at leaf top level, if not root, continue
            Do Until tNode Is rNode
                cMoves.Add TVGN_NEXT            ' inverse navigate using NEXT
                Set tNode = tNode.Previous
            Loop
        End If
        ' now navigate to the desired node from the root
        hItem = SendMessage(tView.Hwnd, TVM_GETNEXTITEM, TVGN_ROOT, ByVal 0&)
        For c = cMoves.Count To 1 Step -1
            hItem = SendMessage(tView.Hwnd, TVM_GETNEXTITEM, cMoves(c), ByVal hItem)
            If hItem = 0 Then Exit For
        Next
        Set cMoves = Nothing
    End If
    pvGetTreeItem = hItem

End Function

Here are three functions that do what we'll want. Can be placed in a module or your form
1. Setting the icon from the image list
Code:

Public Sub SetNodeIcon(tView As TreeView, Node As Node, ZeroBoundIconIndex As Long)

    If Node Is Nothing Or tView Is Nothing Then Exit Sub
    If ZeroBoundIconIndex < 0 Then Exit Sub
    If ZeroBoundIconIndex > 15 Then Exit Sub

    Dim lAttr(0 To 10) As Long
   
    lAttr(1) = pvGetTreeItem(tView, Node)
    If lAttr(1) Then
        lAttr(0) = TVIF_STATE
        lAttr(3) = &HFFFF&
        SendMessage tView.hWnd, TVM_GETITEMA, 0&, lAttr(0)
        lAttr(2) = (lAttr(2) And &HFFFF0FFF) Or (&H1000& * ZeroBoundIconIndex)
        SendMessage tView.hWnd, TVM_SETITEMA, 0&, lAttr(0)
    End If
   
End Sub

2. Retrieving which icon is assigned
Code:

Public Function GetNodeIcon(tView As TreeView, Node As Node) As Long

    If Node Is Nothing Or tView Is Nothing Then Exit Function

    Dim lAttr(0 To 10) As Long
   
    lAttr(1) = pvGetTreeItem(tView, Node)
    If lAttr(1) Then
        lAttr(0) = TVIF_STATE
        lAttr(3) = &HFFFF&
        SendMessage tView.hWnd, TVM_GETITEMA, 0&, lAttr(0)
        GetNodeIcon = (lAttr(2) And &HF000&) \ &H1000&
    End If

End Function

3. This is optional. A method to determine if user is clicking on the icon. See the sample project to see how the Node_Click event uses this method.
Code:

Public Function MouseOverNodeIcon(tView As TreeView, Node As Node, x As Single) As Boolean
   
    ' X must be passed in pixels
   
    If Node Is Nothing Or tView Is Nothing Then Exit Function
   
    Dim tRect(0 To 3) As Long
   
    tRect(0) = pvGetTreeItem(tView, Node)
    If tRect(0) Then
        If SendMessage(tView.hWnd, TVM_GETITEMRECT, 1&, tRect(0)) Then
            MouseOverNodeIcon = (x < tRect(0))
        End If
    End If
End Function

In the sample project, you can click on the icons to toggle the "checkmark"
Oops. Left in some test code. Re-uploaded the zip to fix that.
Attached Images
 
Attached Files

Noob Question about files and date :wave:

$
0
0
Thanks in advance for the replies!

I maked a folder with date as name to store daily reports about the system data in a log.txt file

Is possible to read log files using a calendar?

for example I choosed 10/10/2017 from the calendar. Then the program shows me the 10/10/2017 folder log file

And is possible to make a range of days?

For example from 8/10/2017 to todays date, then the program shows up log files from 8/10/2017 to todays date folder...

Sorry for my english.
PD: I'm a newbie coder

[vb6] Patch Icon/Cursor Resource File Entries

$
0
0
The Resource Editor (ResEdit) in VB can corrupt icon/cursor group data. The corruption is minimal, except PNG-encoded related entries. This corruption should not harm anything except in rare scenarios. Typically, you can expect no harm in these scenarios:

1. The icon/cursor files you add to the resource file via ResEdit only contain one image
2. When the file contains multiple images and all images are square (width = height)

However, this 'corruption' does result in reporting icon/cursor heights and cursor bit depths incorrectly. When multiple images exist for the icon/cursor, there is a potential that Windows will select the wrong image when using resource-related APIs: LoadImage, LookupIconIdFromDirectoryEx, etc.

Examples of corruption:
1. A 32x32 icon is reported as shown. The correct values are to the right, in blue
Width 32 32
Height 64 32
2. A 128x128 icon is reported as shown. The correct values are to the right, in blue
Width 128 128
Height 0 128
3. A 32x32 cursor is reported as shown. The correct values are to the right, in blue
Width 32 32
Height 32 64
Planes 0 1
BitCount 0 4
4. A 128x128 PNG-encoded icon is reported as shown. The correct values are to the right, in blue
Width 0 128
Height 0 128
Planes 18505 1
BitCount 21060 32

Note. After scanning/comparing dozens upon dozens of Windows executables/DLLs and extracting icon/cursor information, it is clear that the ResEdit utility fails to fill the group data correctly. Not surprisingly, icon/cursor group data extracted from vb6.exe, itself, is correctly filled.

This utility will read a VB resource file (.res) and scan the icons/cursors. If any discrepancies are found, they will be displayed. You'll have the option of correcting them and rewriting the res file or saving the updates to a different res file. Might want to consider running this against your res file before you compile your app?

Name:  resPatch.png
Views: 14
Size:  13.3 KB

Edited: See post #2. Found two MS DLLs with 128x128 cursors. Adjusted project to write non-zero width/height values for cursors > 255x255.
Attached Images
 
Attached Files

[VB6] WTSSendMessage

$
0
0
Here are a couple of simple demos.

One just shows how to have a "MsgBox" that times out after some number of seconds if the user does not choose a button.

The other shows how you might raise a "MsgBox" from a Service or a batch Scheduled Task.


Requires Windows 2000 or later, or NT 4.0 with Terminal Services installed.


No idea whether this works on all Editions of Windows (Home, etc.). Only tested on Pro.

You could make more sophisticated use of the API to send messages between machines as well as to the local machine.
Attached Files

FindResource and the IDE

$
0
0
Okay, I need a function that'll just tell me whether a file is in my resources or not.

I'd prefer not to use LoadResData with error trapping because some of my resource files are somewhat large. Therefore, my first idea was to use the FindResource API call. However, this only works once the program is compiled.

So, what I'd like as a ResourceExists(sFileName As String, sResourceType As String) As Boolean function that works the same in the IDE as compiled.

I'm going to do it with error trapping (and LoadResData) for now, but I'd sure like a better solution.

Thanks In Advance,
Elroy

[VB6] InkEdit with Windows SpellCheck

$
0
0
Here is an example of using an InkEdit control in "inkless mode" as a Unicode-aware RichTextBox.

But on Windows 8 and later there is more!

The program turns on the built-in Windows spellcheck capabilities of RichEdit version 8, which lives inside the InkEdit control when running on current versions of Windows.

Code:

Private Const WM_USER As Long = &H400&
Private Const EM_SETLANGOPTIONS As Long = WM_USER + 120&
Private Const IMF_SPELLCHECKING As Long = &H800&
Private Const IMF_TKBPREDICTION As Long = &H1000&
Private Const IMF_TKBAUTOCORRECTION As Long = &H2000&
Private Const EM_SETEDITSTYLE As Long = WM_USER + 204&
Private Const SES_USECTF As Long = &H10000
Private Const SES_CTFALLOWEMBED As Long = &H200000
Private Const SES_CTFALLOWSMARTTAG As Long = &H400000
Private Const SES_CTFALLOWPROOFING As Long = &H800000

Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" ( _
    ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) As Long

Private Sub Form_Load()
    With InkEdit1
        SendMessage .hWnd, _
                    EM_SETLANGOPTIONS, _
                    0, _
                    IMF_SPELLCHECKING _
                Or IMF_TKBPREDICTION _
                Or IMF_TKBAUTOCORRECTION
        SendMessage .hWnd, _
                    EM_SETEDITSTYLE, _
                    SES_USECTF _
                Or SES_CTFALLOWEMBED _
                Or SES_CTFALLOWSMARTTAG _
                Or SES_CTFALLOWPROOFING, _
                    SES_USECTF _
                Or SES_CTFALLOWEMBED _
                Or SES_CTFALLOWSMARTTAG _
                Or SES_CTFALLOWPROOFING
    End With
End Sub

Name:  sshot.png
Views: 29
Size:  6.2 KB

Imagine that. Free spellcheck!


Requirements

Windows 8 or later.
Attached Images
 
Attached Files
Viewing all 1514 articles
Browse latest View live


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