Useful Library

dzt

Active Member
Licensed User
Hello,

Attached is dzHW.zip file which contains dzHW.dll library I made (and dzHWdesktop.dll) and a b4ppc sample of how to use it.

Implements dzHW class with the following methods.

SoftReset: Soft resets the device
MessageBeep(wType): Beep! wTypw determines the type of sound and should be one of MsgBox icons (see B4PPC help, topic "MsgBox Constants")
GetTickCount: A high resolution timing method. Returns time elapsed in miliseconds since the computer/device is booted.
GetACLineStatus: Returns 1 if on AC power, 0 if not.
GetBatteryLifePercent: Returns percentage of Battery Life remaining.
InputPanel: Returns or Sets Soft Input Panel (SIP) state. 1 if it's active, 0 if not. Setting InputPanel = true, activates it and InputPanel = false deactivates it.

The desktop version has limited functionality. Implements only MessageBeep, GetTickCount, GetACLineStatus and GetBatteryLifePercent and not tested at all. Other function are dummy.

Edit (Erel): The most updated library is here: http://www.b4x.com/forum/additional-libraries/384-useful-library-2.html#post2809
See this thread about using this library with the optimized compiler: http://www.b4x.com/forum/questions-help-needed/3796-error-compiling.html
 

Attachments

  • dzHW.ZIP
    114.5 KB · Views: 695

Cableguy

Expert
Licensed User
Longtime User
Awsome job dzt...

I wish i could undertand the dll creation structure..
 

belotrei

Member
Wowwwwwwww..... feel like got a christmas gift! Finally i can get my SIP status... Thank you so MUCH dzt! :sign0060:
 

JJM

Active Member
Licensed User
Longtime User
Thanks so much,Dzt, for your library. It's very useful.

Bye et best regards

JJM
 

alfcen

Well-Known Member
Licensed User
Longtime User
Hello Dimitris,
You did great on this DLL, indeed. Compliments!
Quick question please, dzHW.dll creates a number of objects in Tools/Add Object, such as MyComputer, MyApplication, MyProject, etc.
Please forgive my curiosity, what are these for?

Thanks to your DLL, I put together a precise Delay routine with DoEvents

Sub Delay (ms)
elapse = 0
begin = dz.GetTickCount
do While (elapse < ms)
DoEvents
elapse = dz.GetTickCount - begin
Loop
End Sub
 

dzt

Active Member
Licensed User
New version of dzHW.dll

Hi,

Thank you all for your good words.

alfcen, objects My????? are useless objects created by default, which I forgot to remove in desktop version.

I added 4 new functions:

BringWindowToFront("WindowName"): If Window with Title WindowName is Acive becomes the front window.

BringWindowToFrontC("ClassName"): If Window with Class name ClassName is Acive becomes the front window.

PostMessageToWindow("WindowName", wMsg, wParam, lParam): Sends Message wMsg with parameters wParam and lParam to Window with Title WindowName. Does not wait for the Window to process the message.

PostMessageToWindowC("ClassName", wMsg, wParam, lParam): Sends Message wMsg with parameters wParam and lParam to Window with class name ClassName. Does not wait for the Window to process the message.

For wMsg, wParam, lParam values search the web for winuser.h
One of many google results is: http://doc.ddart.net/msdn/header/include/winuser.h.html

For how to use new functions look at sample test2.sbp included in zip file.

Best Regards
 

Attachments

  • dzHW-2.zip
    6.9 KB · Views: 230
Last edited:

alfcen

Well-Known Member
Licensed User
Longtime User
Hello Dimitris
Thanks a lot for your fast action. All side effects except for SPS are gone.
Visual Studio is an unaffordable suite for me (and probably for many other forum members as well). Please keep the DLL(s) coming.
:sign0098:
Cheers
Robert
 

Louis

Active Member
Licensed User
Longtime User
Hi. I don't know much about C/C++. What valid 32-bit integers can I pass to PostMessageToWindow(), for WMSG, wParam, lParam? I am not following winuser.h. Do I just convert those hexadecimal values to INT32 and use those in my program, and how can I tell what constants to reference when I need a particular feature other than writing to another application? What else can I make other windows do besides typing in other applications? Thank you very much, your library rules!
 

JJM

Active Member
Licensed User
Longtime User
Dimitris,
I have an error with the new version of dzHW.dll.
dzHW.Inputpanel=true (or false) has no action on SIP.
With the old version it works fine.

Bye

JJ M
 

dzt

Active Member
Licensed User
Hello,

JJM thank you for your note and sorry for the bug.
I attached at the same post (#8) new dzHW-2.ZIP with fixed dzHW.dll, please download it again.

alfcen, SPS stands for System Power Status structure used for quering the power status of the device.
You are right about Visual Studio and therefore after first version of dzHW library, I'm using sharpdevelop (http://www.sharpdevelop.net), an open source IDE VS alternative, to develop this librariy. I will post the source code in the near future, so everyone could be able to continue it's development, because I'll stop some moment (not enough free time to spent)

conf, sorry no SMS library for now. I develop these libraries for my own use and just share them with b4ppc community.

Louis, PostMessage functions can be used by your app to communicate with other apps. You can use Bitwise library to convert hex values to decimal at runtime. Maybe I'll post some more examples later in this thread.
 

dzt

Active Member
Licensed User
New version & new dzForm object for desktop

Hi to all,

A new dzHW version is here with more functions and with a new dzForm control for desktop only.
I thought that Form control of B4PPC is not enough for desktop applications so I created this.

For how to use dzForm control see attached B4PPC sample. Documentation for dzForm I'll not post (I hate writing documentation especially in a foreign language) but I think it is simple to understand it. Ask for everything you do not understand.

A simple description for dzHW added function follows.

GetProcesses: Returns in a table of string the names of active processes KillProcess("ProcessName"): Kills the process
GetProcessHandle("ProcessName"): Returns the handle of process with name ProcessName
GetModuleHandle("Modulename"): Return the Handle for a loaded module. ModuleName = "null" returns the handle of myapp
GetActiveWindowHandle: Returns the Handle of the Active Window
GetWindowHandle("ClassName", "WindowName"): Returns the handle of Window with class name ClassName and window name WindowName. ClassName and or WindowName can be null
GetClassName(hWnd, StrLen): Returns in a string the class name of the given hWnd. StrLen the maximum length of class name to return
GetWindowtext(hWnd, StrLen): Returns in a string the window text of the given hWnd. StrLen the maximum length of window name to return
SetWindowText(hWnd, WindowText): Sets the Window Title or Caption of window eith Handle hWnd
GetParent(hWnd): Returns the parent window handle of window with handle hWnd
GetWindowFirst(hWnd): Returns the handle of the first in order window of window with handle hWnd
GetWindowNext(hWnd): Returns the handle of the next in order window of window with handle hWnd
GetWindowChild(hWnd): Returns the first child window of thw window with handle hWnd
PostMessage(hWnd, wMsg, wParam, lParam): Posts a message to the window with hWnd handle
ShowWindow(hWnd, nCmdShow): Send mCmdShow command to the window with handle hWnd. If mCmdShow = 0 hides the window. If mCmdShow = 5 shows the window. See winuser.h as above
GetWindowRect(hWnd): Return a table(4) of int32 with left, top, right, bottom of window with Handle hWnd
IsWindowVisible(hWnd): Returns true if the window with handle hWnd is visible
IsWindow(hWnd): Returns true if the window with handle hWnd is window (!!!)

For how to use these functions see dzSpy I've posted here http://www.b4x.com/forum/showthread.php?t=452

Desktop version source code can be found here http://www.terracom.gr/basic4ppc/files/dzHWdesktop.zip

Device version source code can be found here http://www.terracom.gr/basic4ppc/files/dzHW.zip

Attached dzHW-3.zip contains compiled DLLs.
Attached dzForm-sample.zip contains .sbp sample dzHWDesktop.dll and FormLib.dll.

Regards
 

Attachments

  • dzHW-3.zip
    15.2 KB · Views: 312
  • dzForm-sample.zip
    12.2 KB · Views: 234
  • dzHWForm.jpg
    dzHWForm.jpg
    25.7 KB · Views: 165

alfcen

Well-Known Member
Licensed User
Longtime User
:sign0188:
How do you find time to sleep?
Amazing work, by all means!
I second your feeling about manuals. You have done so much for the forum. The example code is more than sufficient help.
Respectful greetings
Robert
 

agraham

Expert
Licensed User
Longtime User
Hi dzt. Many thanks for the kind words in another thread. I know you hate documentation so I have attached an attempt at a help file for your dzHW library. I would appreciate some comments on the dzProcesses class in the device library, is it intended for use with B4PPC? If so a few words on what the members do perhaps?- and any other comments of course.

Hi everyone else. This chm is a work in progress I will post the final version in a few days time.
 

Attachments

  • dzHWhelp.zip
    10 KB · Views: 169

dzt

Active Member
Licensed User
Hello agraham,

Thank you very very very much for your work.
dzProcesses is a helper class and there is no need to be visible to Basic4ppc.

I'll post more comments in the near future, since I'm very busy for now.

Thanks again!

@Erel: What do you say about hiding protected classes ?
 
Top