Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
kind of works? reading multiple mice: any c programmers want to look at this?
#49
(09-12-2022, 09:25 PM)Spriggsy Wrote: System won't print anything, it just exits the program with that code. The function is basically being called by STR$. Not sure what you're asking for on the other question, though. The events are all there to run the window created by CreateWindow and the callback function is registered with RegisterClass.

I see now that you mean line 381. Anyways, there's no way for it to be firing anything after WinMain because System kills the program. Everything is a bit out of order anyways. You wouldn't want your test outside of the loop that is displaying the window.

UPDATE: 
I haven't given up on this Spriggsy! Just got a little busy, is all... 
This, the MIDI thing, the WAV file thing, all still in the pipe. 
I figured it can't hurt to do some reading up on these API calls - below are my notes in case it helps anyone. 
I still am not convinced it's impossible to populate hwndMain with _WindowHandle of the existing app, and get the API functions to act on that. 
Also, does the RawInput require an actual window to work? 
What about the Windows desktop? 
Anyway, I will continue to play with this. 
If you have any breakthroughs, let me know! :-D

Code: (Select All)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
WINDOWS API COMMANDS
----------------------------------------------------------------------------------------------------------------------------------------------------------------
GetRawInputDeviceList
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdevicelist
    Enumerates the raw input devices attached to the system.
RegisterRawInputDevices
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerrawinputdevices
    Registers the devices that supply the raw input data.
GetRawInputData
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdata
    Retrieves the raw input from the specified device.
    Parameters:
        [in] hRawInput
            Type: HRAWINPUT
            A handle to the RAWINPUT structure. This comes from the lParam in WM_INPUT.
        [in] uiCommand
            Type: UINT
            The command flag. This parameter can be one of the following values.
            Value                   Meaning
            RID_HEADER 0x10000005   Get the header information from the RAWINPUT structure.
            RID_INPUT  0x10000003   Get the raw data from the RAWINPUT structure.
        [out, optional] pData
            Type: LPVOID
            A pointer to the data that comes from the RAWINPUT structure.
            This depends on the value of uiCommand.
            If pData is NULL, the required size of the buffer is returned in *pcbSize.
        [in, out] pcbSize
            Type: PUINT
            The size, in bytes, of the data in pData.
        [in] cbSizeHeader
            Type: UINT
            The size, in bytes, of the RAWINPUTHEADER structure.
        Return value
            Type: UINT
            If pData is NULL and the function is successful, the return value is 0.
            If pData is not NULL and the function is successful,
            the return value is the number of bytes copied into pData.
            If there is an error, the return value is (UINT)-1.
    Remarks
    GetRawInputData gets the raw input one RAWINPUT structure at a time.
    In contrast, GetRawInputBuffer gets an array of RAWINPUT structures.

DrawText
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-drawtext
    The DrawText function draws formatted text in the specified rectangle.
    It formats the text according to the specified method (expanding tabs,
    justifying characters, breaking lines, and so forth).
    To specify additional formatting options, use the DrawTextEx function.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
OTHERS:
FillRect function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-fillrect
    The FillRect function fills a rectangle by using the specified brush.
    This function includes the left and top borders, but excludes the right and bottom borders of the rectangle.
    Parameters
        [in] hDC
            A handle to the device context.
        [in] lprc
            A pointer to a RECT structure that contains the logical coordinates of the rectangle to be filled.
        [in] hbr
            A handle to the brush used to fill the rectangle.
        Return value
            If the function succeeds, the return value is nonzero.
            If the function fails, the return value is zero.
GetDC function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc
    The GetDC function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the DC. The device context is an opaque data structure, whose values are used internally by GDI.
    The GetDCEx function is an extension to GetDC, which gives an application more control over how and whether clipping occurs in the client area.
    Parameters
        [in] hWnd
            A handle to the window whose DC is to be retrieved.
            If this value is NULL, GetDC retrieves the DC for the entire screen.
        Return value
            If the function succeeds, the return value is a handle to the DC for the specified window's client area.
            If the function fails, the return value is NULL.
LoadBitmapA function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadbitmapa
LoadBitmapW function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadbitmapw
OffsetRect function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-offsetrect
RedrawWindow function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-redrawwindow
ReleaseDC function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-releasedc
SetRect function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setrect
WindowFromDC function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-windowfromdc
BeginPaint function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-beginpaint

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
GetModuleHandle
    https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlea
    GetModuleHandleA function (libloaderapi.h)
    Retrieves a module handle for the specified module. The module must have been loaded by the calling process.
    To avoid the race conditions described in the Remarks section, use the GetModuleHandleEx function.
        GetModuleHandleExA function (libloaderapi.h)
        https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandleexa
        Retrieves a module handle for the specified module and increments the module's reference count
        unless GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT is specified.
        The module must have been loaded by the calling process.
RegisterClassEx
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerclassexa
    RegisterClassExA function (winuser.h)
    Registers a window class for subsequent use in calls to the CreateWindow or CreateWindowEx function.
CreateWindowEx
    CreateWindowExA function (winuser.h)
        https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowexa
        Creates an overlapped, pop-up, or child window with an extended window style;
        otherwise, this function is identical to the CreateWindow function.
        For more information about creating a window
        and for full descriptions of the other parameters of CreateWindowEx, see CreateWindow.
            CreateWindowA macro (winuser.h)
            https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowa
ShowWindow
    ShowWindow function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow
    Sets the specified window's show state.
    Parameters
    [in] hWnd
        Type: HWND
        A handle to the window.
    [in] nCmdShow
        Type: int
        Controls how the window is to be shown.
        This parameter is ignored the first time an application calls ShowWindow,
        if the program that launched the application provides a STARTUPINFO structure.
        Otherwise, the first time ShowWindow is called, the value should be the value obtained
        by the WinMain function in its nCmdShow parameter. In subsequent calls, this parameter
        can be one of the following values.
        Value                             Meaning
        0 SW_HIDE                         Hides the window and activates another window.
        1 SW_SHOWNORMAL, SW_NORMAL        Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
        2 SW_SHOWMINIMIZED                Activates the window and displays it as a minimized window.
        3 SW_SHOWMAXIMIZED, SW_MAXIMIZE   Activates the window and displays it as a maximized window.
        4 SW_SHOWNOACTIVATE               Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except that the window is not activated.
        5 SW_SHOW                         Activates the window and displays it in its current size and position.
        6 SW_MINIMIZE                     Minimizes the specified window and activates the next top-level window in the Z order.
        7 SW_SHOWMINNOACTIVE              Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated.
        8 SW_SHOWNA                       Displays the window in its current size and position. This value is similar to SW_SHOW, except that the window is not activated.
        9 SW_RESTORE                      Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
        10 SW_SHOWDEFAULT                 Sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.
        11 SW_FORCEMINIMIZE               Minimizes a window, even if the thread that owns the window is not responding. This flag should only be used when minimizing windows from a different thread.
    Return value
        Type: BOOL
        If the window was previously visible, the return value is nonzero.
        If the window was previously hidden, the return value is zero.
UpdateWindow
    UpdateWindow function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-updatewindow
    The UpdateWindow function updates the client area of the specified window
    by sending a WM_PAINT message to the window if the window's update region is not empty.
    The function sends a WM_PAINT message directly to the window procedure of the specified window,
    bypassing the application queue. If the update region is empty, no message is sent.
    Parameters
        [in] hWnd
        Handle to the window to be updated.
    Return value
        If the function succeeds, the return value is nonzero.
        If the function fails, the return value is zero.
DefWindowProc
    DefWindowProcW function (winuser.h)
        https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-defwindowprocw
        Calls the default window procedure to provide default processing for any window messages that an application does not process. This function ensures that every message is processed.
        DefWindowProc is called with the same parameters received by the window procedure.
        Parameters
            [in] hWnd
                Type: HWND
                A handle to the window procedure that received the message.
            [in] Msg
                Type: UINT
                The message.
            [in] wParam
                Type: WPARAM
                Additional message information.
                The content of this parameter depends on the value of the Msg parameter.
            [in] lParam
                Type: LPARAM
                Additional message information.
                The content of this parameter depends on the value of the Msg parameter.
        Return value
            Type: LRESULT
            The return value is the result of the message processing and depends on the message.
    DefWindowProcA function (winuser.h)
        https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-defwindowproca
        Calls the default window procedure to provide default processing for any window messages that an application does not process. This function ensures that every message is processed.
        DefWindowProc is called with the same parameters received by the window procedure.
        Parameters
            [in] hWnd
                Type: HWND
                A handle to the window procedure that received the message.
            [in] Msg
                Type: UINT
                The message.
            [in] wParam
                Type: WPARAM
                Additional message information.
                The content of this parameter depends on the value of the Msg parameter.
            [in] lParam
                Type: LPARAM
                Additional message information.
                The content of this parameter depends on the value of the Msg parameter.
        Return value
            Type: LRESULT
            The return value is the result of the message processing and depends on the message.
GetClientRect
    GetClientRect function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclientrect
    Retrieves the coordinates of a window's client area.
    The client coordinates specify the upper-left and lower-right corners of the client area.
    Because client coordinates are relative to the upper-left corner of a window's client area,
    the coordinates of the upper-left corner are (0,0).
    Parameters
        [in] hWnd
            Type: HWND
            A handle to the window whose client coordinates are to be retrieved.
        [out] lpRect
            Type: LPRECT
            A pointer to a RECT structure that receives the client coordinates.
            The left and top members are zero.
            The right and bottom members contain the width and height of the window.
    Return value
        Type: BOOL
        If the function succeeds, the return value is nonzero.
        If the function fails, the return value is zero.
        To get extended error information, call GetLastError.
InvalidateRect
    InvalidateRect function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-invalidaterect
    The InvalidateRect function adds a rectangle to the specified window's update region.
    The update region represents the portion of the window's client area that must be redrawn.
    Parameters
        [in] hWnd
            A handle to the window whose update region has changed.
            If this parameter is NULL, the system invalidates and redraws all windows,
            not just the windows for this application, and sends the WM_ERASEBKGND
            and WM_NCPAINT messages before the function returns.
            Setting this parameter to NULL is not recommended.
        [in] lpRect
            A pointer to a RECT structure that contains the client coordinates of the rectangle
            to be added to the update region.
            If this parameter is NULL, the entire client area is added to the update region.
        [in] bErase
            Specifies whether the background within the update region is to be erased when the
            update region is processed. If this parameter is TRUE, the background is erased when
            the BeginPaint function is called.
            If this parameter is FALSE, the background remains unchanged.
    Return value
        If the function succeeds, the return value is nonzero.
        If the function fails, the return value is zero.
OffsetRect
    OffsetRect function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-offsetrect
    The OffsetRect function moves the specified rectangle by the specified offsets.
    Parameters
        [in, out] lprc
            Pointer to a RECT structure that contains the logical coordinates of the rectangle to be moved.
        [in] dx
            Specifies the amount to move the rectangle left or right.
            This parameter must be a negative value to move the rectangle to the left.
        [in] dy
            Specifies the amount to move the rectangle up or down.
            This parameter must be a negative value to move the rectangle up.
    Return value
        If the function succeeds, the return value is nonzero.
        If the function fails, the return value is zero.
BeginPaint
    BeginPaint function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-beginpaint
    The BeginPaint function prepares the specified window for painting and fills a
    PAINTSTRUCT structure with information about the painting.
    Parameters
        [in] hWnd
            Handle to the window to be repainted.
        [out] lpPaint
            Pointer to the PAINTSTRUCT structure that will receive painting information.
    Return value
        If the function succeeds, the return value is the handle to a display device context for the specified window.
        If the function fails, the return value is NULL, indicating that no display device context is available.
EndPaint
    EndPaint function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-endpaint
    The EndPaint function marks the end of painting in the specified window.
    This function is required for each call to the BeginPaint function, but only after painting is complete.
    Parameters
        [in] hWnd
            Handle to the window that has been repainted.
        [in] lpPaint
            Pointer to a PAINTSTRUCT structure that contains the painting information retrieved by BeginPaint.
    Return value
        The return value is always nonzero.

GetMessage
    GetMessage function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessage
    Retrieves a message from the calling thread's message queue.
    The function dispatches incoming sent messages until a posted message is available for retrieval.
    Unlike GetMessage, the PeekMessage function does not wait for a message to be posted before returning.
    (see above URL for details)
TranslateMessage
    TranslateMessage function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-translatemessage
    Translates virtual-key messages into character messages.
    The character messages are posted to the calling thread's message queue,
    to be read the next time the thread calls the GetMessage or PeekMessage function.
DispatchMessage
    DispatchMessage function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dispatchmessage
    Dispatches a message to a window procedure.
    It is typically used to dispatch a message retrieved by the GetMessage function.
SendMessage
    SendMessage function (winuser.h)
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessage
    Sends the specified message to a window or windows.
    The SendMessage function calls the window procedure for the specified window
    and does not return until the window procedure has processed the message.
    To send a message and return immediately, use the SendMessageCallback or
    SendNotifyMessage function. To post a message to a thread's message queue and
    return immediately, use the PostMessage or PostThreadMessage function.

MAKEINTRESOURCE
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-makeintresourcea
    Converts an integer value to a resource type compatible with the resource-management functions.
    This macro is used in place of a string containing the name of the resource.

Library
    MAKELPARAM
        MAKELPARAM macro (winuser.h)
        https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-makelparam
        Creates a value for use as an lParam parameter in a message.
        The macro concatenates the specified value
        Parameters
            l = The low-order word of the new value.
            h = The high-order word of the new value.
        Return value: None
    MAKELONG
        MAKELONG macro
        https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms632660(v=vs.85)
        Creates a LONG value by concatenating the specified values.
        Parameters
            wLow = The low-order word of the new value.
            wHigh = The high-order word of the new value.
        Return value
            Type: DWORD
            The return value is a LONG value.

windowsx
    GET_Y_LPARAM
        GET_Y_LPARAM macro (windowsx.h)
        https://docs.microsoft.com/en-us/windows/win32/api/windowsx/nf-windowsx-get_y_lparam
        Retrieves the signed y-coordinate from the given LPARAM value.
        Parameters
            lp = The data from which the y-coordinate is to be extracted.
        Return value
            Type: int
            Y-coordinate.
        Remarks
            Use GET_Y_LPARAM instead of HIWORD to extract signed coordinate data.
            Negative screen coordinates may be returned on multiple monitor systems.
    GET_X_LPARAM
        GET_X_LPARAM macro (windowsx.h)
        https://docs.microsoft.com/en-us/windows/win32/api/windowsx/nf-windowsx-get_x_lparam
        Retrieves the signed x-coordinate from the specified LPARAM value.
        Parameters
            lp = The data from which the x-coordinate is to be extracted.
        Return value
            Type: int
            X-coordinate.
        Remarks
            Use GET_X_LPARAM instead of LOWORD to extract signed coordinate data.
            Negative screen coordinates may be returned on multiple monitor systems.

----------------------------------------------------------------------------------------------------------------------------------------------------------------
WINDOWS REFERENCE
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Windows and Messages
https://docs.microsoft.com/en-us/windows/win32/winmsg/windowing
   
    Windows (Windows and Messages)
    https://docs.microsoft.com/en-us/windows/win32/winmsg/windows
   
        Window Reference
        https://docs.microsoft.com/en-us/windows/win32/winmsg/window-reference
           
            Windows (Windows and Messages) = Discusses windows in general.
            https://docs.microsoft.com/en-us/windows/win32/winmsg/windows
           
            Window Constants
            https://docs.microsoft.com/en-us/windows/win32/winmsg/constants
           
            Window functions
            https://docs.microsoft.com/en-us/windows/win32/winmsg/window-functions
           
            Window Macros
            https://docs.microsoft.com/en-us/windows/win32/winmsg/window-macros
           
            Window Messages (Windows and Messages)
            https://docs.microsoft.com/en-us/windows/win32/winmsg/window-messages
           
            Window Notifications
            https://docs.microsoft.com/en-us/windows/win32/winmsg/window-notifications
           
            Window Structures
            https://docs.microsoft.com/en-us/windows/win32/winmsg/window-structures
           
    Window Classes (Windows and Messages) = Describes the types of window classes, how the system locates them, and the elements that define the default behavior of windows that belong to them.
    https://docs.microsoft.com/en-us/windows/win32/winmsg/window-classes
   
    Window Procedures = Discusses window procedures. Every window has an associated window procedure that processes all messages sent or posted to all windows of the class.
    https://docs.microsoft.com/en-us/windows/win32/winmsg/window-procedures
   
    Messages and Message Queues = Describes messages and message queues and how to use them in your applications.
    https://docs.microsoft.com/en-us/windows/win32/winmsg/messages-and-message-queues
   
    Timers = Discusses timers. A timer is an internal routine that repeatedly measures a specified interval, in milliseconds.
    https://docs.microsoft.com/en-us/windows/win32/winmsg/timers
   
    Window Properties = Discusses window properties. A window property is any data assigned to a window.
    https://docs.microsoft.com/en-us/windows/win32/winmsg/window-properties
   
    Configuration = Describes the functions that can be used to control the configuration of system metrics and various system attributes such as double-click time, screen saver time-out, window border width, and desktop pattern.
    https://docs.microsoft.com/en-us/windows/win32/winmsg/configuration
   
    Hooks = Discusses hooks. A hook is a point in the system message-handling mechanism where an application can install a subroutine to monitor the message traffic.
    https://docs.microsoft.com/en-us/windows/win32/winmsg/hooks
   
    Multiple Document Interface = Discusses the Multiple Document Interface which is a specification that defines a user interface for applications that enable the user to work with more than one document at the same time.
    https://docs.microsoft.com/en-us/windows/win32/winmsg/multiple-document-interface
Reply


Messages In This Thread
RE: kind of works? reading multiple mice: any c programmers want to look at this? - by madscijr - 09-15-2022, 01:22 PM



Users browsing this thread: 18 Guest(s)