Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. changing what a pushbutton looks like

changing what a pushbutton looks like

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialgraphics
12 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Christian Graus

    Basically, you set the control to be owner drawn, then you draw it however you like. This[^] article may be of some help. Christian Graus - Microsoft MVP - C++

    E Offline
    E Offline
    ebinaini
    wrote on last edited by
    #3

    thank you for advance i have change my article. can you help me? nothing

    C 1 Reply Last reply
    0
    • E ebinaini

      thank you for advance i have change my article. can you help me? nothing

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #4

      What did you want help with ? Christian Graus - Microsoft MVP - C++

      E 1 Reply Last reply
      0
      • C Christian Graus

        What did you want help with ? Christian Graus - Microsoft MVP - C++

        E Offline
        E Offline
        ebinaini
        wrote on last edited by
        #5

        this is my code for useing ADO link Paradox DataBase. but it throw wrong so maybe you can help me. i will greatly appreciated BOOL CTM21App::InitInstance() { CString connectsource; _ConnectionPtr pCon; AfxOleInit(); AfxEnableControlContainer(); pCon.CreateInstance(__uuidof(Connection)); try { connectsource.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%d\\work\TM21Vol4\gentan500\Database;Extended Properties=Paradox 4.81;Persist Security Info=False"); pCon->Open((_bstr_t)connectsource,"","",adModeUnknown); } catch(_com_error e) { AfxMessageBox("open .db wrong"); return FALSE; } } nothing

        C 1 Reply Last reply
        0
        • T Tim Zorn

          can someone plz give me a tutorial on how to change a pushbuttons appearance using GDI. i'd like to do it completely in Win32/SDK also Thanks In Advance, Tim Zorn

          N Offline
          N Offline
          normanS
          wrote on last edited by
          #6

          An alternative to making a fully owner-drawn button, is to put an icon or bitmap on a standard pushbutton. From a quick look at some old SDK-level code, the code is something like this: buttonHwnd = CreateWindow("button", "", WS_CHILD | WS_VISIBLE | BS_ICON | BS_PUSHBUTTON, ButtonXPos, ButtonYPos, ButtonWidth, ButtonHeight, hwndMain, (HMENU)buttonId, hAppInst, NULL); hButtonIcon = LoadIcon(hAppInst, MAKEINTRESOURCE(IDI_ButtonIcon)); SendMessage(buttonHwnd , BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)(HANDLE)hButtonIcon); Right at the moment I forget what all the parameters are, but if you need help, just ask.

          T 1 Reply Last reply
          0
          • E ebinaini

            this is my code for useing ADO link Paradox DataBase. but it throw wrong so maybe you can help me. i will greatly appreciated BOOL CTM21App::InitInstance() { CString connectsource; _ConnectionPtr pCon; AfxOleInit(); AfxEnableControlContainer(); pCon.CreateInstance(__uuidof(Connection)); try { connectsource.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%d\\work\TM21Vol4\gentan500\Database;Extended Properties=Paradox 4.81;Persist Security Info=False"); pCon->Open((_bstr_t)connectsource,"","",adModeUnknown); } catch(_com_error e) { AfxMessageBox("open .db wrong"); return FALSE; } } nothing

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #7

            I'm sorry, I'm really not sure. What's the _com_error you catch, have you looked ? Christian Graus - Microsoft MVP - C++

            1 Reply Last reply
            0
            • N normanS

              An alternative to making a fully owner-drawn button, is to put an icon or bitmap on a standard pushbutton. From a quick look at some old SDK-level code, the code is something like this: buttonHwnd = CreateWindow("button", "", WS_CHILD | WS_VISIBLE | BS_ICON | BS_PUSHBUTTON, ButtonXPos, ButtonYPos, ButtonWidth, ButtonHeight, hwndMain, (HMENU)buttonId, hAppInst, NULL); hButtonIcon = LoadIcon(hAppInst, MAKEINTRESOURCE(IDI_ButtonIcon)); SendMessage(buttonHwnd , BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)(HANDLE)hButtonIcon); Right at the moment I forget what all the parameters are, but if you need help, just ask.

              T Offline
              T Offline
              Tim Zorn
              wrote on last edited by
              #8

              thanks a bunch man. but how do u get it to have text along with an image. also how do i get the image to stretch across the whole button

              N 2 Replies Last reply
              0
              • C Christian Graus

                Basically, you set the control to be owner drawn, then you draw it however you like. This[^] article may be of some help. Christian Graus - Microsoft MVP - C++

                T Offline
                T Offline
                Tim Zorn
                wrote on last edited by
                #9

                how do u do owner-drawn stuff. i looked at the article u linked to but i didnt understand much of the source

                1 Reply Last reply
                0
                • T Tim Zorn

                  thanks a bunch man. but how do u get it to have text along with an image. also how do i get the image to stretch across the whole button

                  N Offline
                  N Offline
                  normanS
                  wrote on last edited by
                  #10

                  I put bitmaps and icons on the buttons, but the basis was standard Windows pushbuttons. I don't have time to check now, but I think I made the size of the icons / bitmap such that they neatly fitted onto the flat grey foreground of the button. I can't remember what happens if the bitmap or icon is too big for the foreground. I would guess that if the bitmap if too big, you loose the 3D "animation" effect at the edges of the button. To have text with an image, maybe just include the text in your bitmap / icon. I will try to have a look at what I did later today (I'm on a course for the next 9 hours.)

                  1 Reply Last reply
                  0
                  • T Tim Zorn

                    thanks a bunch man. but how do u get it to have text along with an image. also how do i get the image to stretch across the whole button

                    N Offline
                    N Offline
                    normanS
                    wrote on last edited by
                    #11

                    Sorry - I had a quick look, but the earliest version I have on my work PC uses Icons on buttons (that version uses the code I posted previously.) If it is any use to you, I am sure I can find a backup disk at home with a version which puts bitmaps on buttons. Let me know if I must find it! (Or any other similar questions.)

                    T 1 Reply Last reply
                    0
                    • N normanS

                      Sorry - I had a quick look, but the earliest version I have on my work PC uses Icons on buttons (that version uses the code I posted previously.) If it is any use to you, I am sure I can find a backup disk at home with a version which puts bitmaps on buttons. Let me know if I must find it! (Or any other similar questions.)

                      T Offline
                      T Offline
                      Tim Zorn
                      wrote on last edited by
                      #12

                      i know how to put bitmaps on buttons now but i dont know how to do it the way i want. i want a bitmap to be stretched across the button and i want to be able to put text on the button. i have found an article that does it but i dont understand the source so im asking for help. For Example: a program called ICQ is skinned so it has custom buttons. but when i look at it's resourses the buttons are not ownerdrawn. all i want to do is make a custom button that has text on it. i dont even need the handling for if its selected, default, etc cuz i can find that out myself help would be appriciated thx:)

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups