Results 1 to 7 of 7

Thread: changng object properties in C

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    64

    Question

    how do you change a object's properties in 32 bit C? i haev the lcc win32 compiler, it's awesome but i'm still kinda new, please give me an examople how to dothis:

    How do you enable/disable a button in C?


  2. #2
    Guest
    I have Visual C++ and here is how you disable a button. Right-click the Button, select properties, and click on the Disabled Checkbox.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    What do you mean, enable/disable. Is that a button in a dialogue box? If you are using anything like MFC/OWL then it's different. If you are using 'bare-foot' API, then look up the SendDlgItemMessage function, and send the WM_ENABLE message. Disabling is slightly strange, and you'll need to check MSDN for that. http://msdn.microsoft.com/library

    --- one edit later ---
    sorry meg, was writing my reply at the same time as you!
    ...oh well. If he's not using MSVC then that won't work.


    [Edited by parksie on 07-01-2000 at 10:47 PM]
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    64

    megatron... i ment at runtime, yeahi'm using bare API

    megatron... i ment at runtime, yeah i'm using bare API, cas my compiler is LCC win32 C compiler. i also have vc++ 6 prof edition but lcc makes nice small fast exe's and does all the same things.


    i know that is the api call but can u give me and example pleaseeeeeeeee, thanks

  5. #5
    Guest
    Use the EnableWindow API. I can tell you to do it in VC++. First, when you create your Button, you must add a Member Variable using the Class Wizard. Call it m_bTest.

    Put this code in another Button.

    Code:
    void CDialogtestDlg::MyButton() 
    {
    	// Disable the Button
    	m_bTest.EnableWindow(FALSE);
    }

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    64
    i don't know VC++, i don't even knwo what the heck were thoughs :: for?

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    In C++, when you create an object, by definition it has its own 'namespace'. For example:

    Code:
    namespace A {
        int i;
        string mystr;
    }
    
    namespace B {
        int i;
        string anotherstring;
    }
    
    void function() {
        int j;
        string x;
        j = i;             // WRONG: which namespace?
        j = A::i;          // RIGHT: select from namespace A
        j = B::i;          // RIGHT: select from namespace B
        x = mystr;         // RIGHT: no need to select namespace
        x = anotherstring; // RIGHT: no need to select namespace
    }
    So, when you define your class:

    Code:
    class MyClass {
    public:
        MyClass();
        virtual ~MyClass();
    
        void MyFunction(int iParam);
        int m_iMyMemberVariable;
    }
    They are now under the namespace 'MyClass'.

    So, to define the functions:

    Code:
    MyClass::MyFunction(int iParam) {
        m_iMyMemberVariable = iParam;
    }
    The '::' selects the namespace, so the compiler knows that you are defining the 'MyFunction' function under namespace 'MyClass'. There is no need to select the namespace for m_iMyMemberVariable because that is the default namespace for that function now.

    Back to your original question, though, Megatron was using MFC (Microsoft Foundation Classes) which make Windows programming a lot easier. The CWnd::EnableWindow function is a wrapper for the API EnableWindow function, which can be accessed by ::EnableWindow (::XX means select XX out of the default namespace, which everything which is not already in a namespace ends up in). This is defined as:

    Code:
        void EnableWindow(HWND hWindow, BOOL bEnableFlag);
    You need to pass the HWND of the button, and either 1 or 0 for bEnableFlag to enable or disable respectively.



    [Edited by parksie on 07-02-2000 at 05:30 AM]
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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