Results 1 to 5 of 5

Thread: Need help understanding something

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    Need help understanding something

    ok here is exactly what Im trying to do,

    I have to insert 10 strings in 10 different textboxes in the shortest possible time (half a second counts), so I thought the best way is to store them all in a program before the timer starts and then simply press TAB 10 times when the timer starts, and my application would paste them each in a separate text box...
    so I want it to paste it on the old focused control then move to the other control ...
    After help of some friends, I got this code
    Code:
    #include <windows.h>
    #include <stdio.h>
    int WINAPI WinMain (HINSTANCE hThisInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR lpszArgument,
                         int nFunsterStil)
    
    {
    HWND hWnd;
        for(;;)
        {
            MSG Msg;
            while(GetMessage(&Msg, NULL, 0, 0)){
                if(Msg.message == WM_KEYUP && Msg.wParam == VK_TAB){
                    PostMessage(Msg.hwnd, WM_PASTE, 0, 0);
                    printf("K\n"); //Never shows this == not entering the if statment ... why ?
                    // you might need to try GetFocus() instead of Msg.hwnd
                }              
                if(!IsDialogMessage(hWnd, &Msg)){
                    TranslateMessage(&Msg);
                    DispatchMessage(&Msg);
                }
            }
        }
        return 0;
    }
    the code is never entering the If statment, even when I press TAB
    I tried adding printf("test\n"); to check, it never shows

    why is it not entering the If Statment ?
    Im using Visual Studio 2008 Professional Edition
    .Net Framework 3.5

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Need help understanding something

    May I ask why you're doing that when there is a function called SetWindowText ?

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    Re: Need help understanding something

    you mean instead of PostMessage ?
    could you please provide an example on how to use it ? thx
    Im using Visual Studio 2008 Professional Edition
    .Net Framework 3.5

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Need help understanding something

    Code:
    for (int i = 0; i < NUMBER_OF_TEXTBOXES; i++)
    {
        SetWindowText(hwnd[i], "New Text");
    }
    Each time you create a new textbox, store the handle from CreateWindow/Ex into a hwnd array.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    Re: Need help understanding something

    I dont want to create any text box ... I want to capture the tab press where ever it is pressed (my case on a website running by firefox) and when the tab is pressed I want to paste the clipboard and move to the next text box...

    how can I do this?
    Im using Visual Studio 2008 Professional Edition
    .Net Framework 3.5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width