Streamline Your API Declares, Part 2

Streamline Your API Declares, Part 2

While we are speaking of SendMessage, there is another trick youmay find interesting enough to include in your programming habits.When used with some particular messages, the lParam argument isreally considered as two words combined. The EM_LINESCROLL canscroll a multilined text box, the low word of lParam containsthe number of lines to scroll vertically (positive values scrollup), and the high word contains the number of lines to scrollhorizontally (positive values scroll left); other, similar messagesare EM_SETSEL for text boxes, CB_SETEDITSEL for combo boxes, andLB_SELITEMRANGE for list boxes. In such cases you need to preparethe long value to be passed to the routine, which slows down yourcode and makes it less readable. It seems that a simple multiplicationshould do the work:

 ' scroll a multilined textbox "HO" ' lines horizontally' and "VE" lines vertically' beware: this approach does NOT ' work properlylongValue& = HO * 65536& + VE

The above code does not work correctly when HO is positive andVE is negative, and for a more general scrolling routine you haveto resort to a more convoluted and slower method:

 tmp$ = Right$("000" & Hex$(HO), 4) & _        Right$("000" & Hex$(VE), 4)longValue = Val("&H" & tmp$)

The solution is declaring an aliased function that splits thelParam into two distinct parameters of Integer type, as in:

 Declare Sub SendMessageSub2 Lib _        "User" Alias "SendMessage" _        (ByVal hWnd%, ByVal msg%, ByVal _        wParam, ByVal lParam1%, _        ByVal lParam2%)

Now the call is much simpler:

 SendMessageSub2 Text1.hWnd, _        EM_LINESCROLL, 0, HO, VE

The trick works because a push of a Long value onto the stackhas the same effect as the push of its high word followed by thepush of its low word.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes