C GUI Problems

This is a discussion on C GUI Problems within the Windows Programming forums, part of the Platform Specific Boards category; Hello, i made a C Program that identify the n of bytes of a determined resource. Here is the code: ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    39

    C GUI Problems

    Hello, i made a C Program that identify the n of bytes of a determined resource.


    Here is the code:


    rc.rc(Resource file)
    Code:
    #include "rc.h"
    
    
    DD DIALOGEX 6,5,167,49
    CAPTION "Testando"
    {
    CONTROL "Digite alguma coisa:",label,"Static",0x50000000,50,3,66,20
    CONTROL "",txt,"Edit",0x500100C0,4,14,160,13,0x00000200
    CONTROL "Criar",btn,"Button",0x50010001,56,29,54,13
    }
    data RCDATA
    {
    "C:\\cs.exe"
    }

    rc.h(Header File)

    Code:
    #define DD 1
    #define btn 2
    #define data 3
    #define txt 4
    #define label 5


    Main File

    Code:
    #include<windows.h>
    #include "rc.h"
    
    
    
    
    
    
    LRESULT CALLBACK WinProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
    int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
    {
    DialogBox(hInstance,MAKEINTRESOURCE(DD),NULL,(DLGPROC)WinProc);
    }
    
    
    
    
    LRESULT CALLBACK WinProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
    {
    switch(msg)
    {
    case WM_CLOSE:
         PostQuitMessage(0);
    break;
    
    case WM_COMMAND:
         if(wParam==btn)
         {
         HRSRC hRes = FindResource(0, MAKEINTRESOURCE(DD), RT_RCDATA);
         HGLOBAL hMem = LoadResource(0, hRes);
         void *pMem = LockResource(hMem);
         DWORD size = SizeofResource(0, hRes);
         SetDlgItemInt(hwnd,txt,size,false);
    
    
       
         }
         break;
    }
    return 0;
    }



    Well the problem is that the program not return the number of bytes, its return 0
    Someone knows the problem?


    Thanks
    Bye

  2. #2
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223
    Well technically the program can only return 0, see second last line,
    Code:
    return 0;
    I don't know if you mean one of the functions, provide more detail into what function that returns 0 and what it is that you intend it to do.
    If you want to return the number of bytes (i am assuming the DWORD size), then try returning that. Also pMem is not used, so there is not much point in declaring it.
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    39
    Hello Again


    The line

    Code:
    Return 0;
    is not the problem, if you change this line

    Code:
    SetDlgItemInt(hwnd,txt,size,false);

    by this:

    Code:
    SetDlgItemInt(hwnd,txt,"2222",false);

    So the program return the numer 2222
    =/

    The problem is on some of resources functions, the variable "size" are not working, and I dont know why



    Bye

  4. #4
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223
    You have a dialog box as a resource, wouldn't you want to just display it? This can be done in one line (avoiding all this size stuff):
    Code:
    DialogBox(hInstance, TEXT ("DD"), hwnd, DlgProc);
    If the program is returning text of a control in a dialog box, setting it, will return whatever you set it to, are you sure you shouldn't be using GetDlgInt?
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Win32 API GUI problems
    By Cha0sBG in forum Windows Programming
    Replies: 7
    Last Post: 06-05-2009, 05:35 PM
  2. .NET And GUI Programming :: C++
    By kuphryn in forum C++ Programming
    Replies: 4
    Last Post: 01-27-2002, 04:22 PM
  3. GUI Programming :: C++ Exclusive
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 01-25-2002, 03:22 PM
  4. GUI help
    By z33z in forum Windows Programming
    Replies: 8
    Last Post: 12-13-2001, 09:16 PM
  5. GUI (Graphical User Interface) Help Needed
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 10-11-2001, 11:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21