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. MFC->How to create different-shaped buttons in runtime?

MFC->How to create different-shaped buttons in runtime?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++helpquestion
1 Posts 1 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.
  • L Offline
    L Offline
    l00p1n6
    wrote on last edited by
    #1

    problem: i need different-shaped buttons to be placed in client area in runtime. for example: rightclick in client area opens context menu with options: round button triangle button by clicking on one of the above appropriate button shoud be drawn in client area. this button (like all others created this way) should have all standard properties of a button (CButton) my experiment: i've tried with SetWindowRgn but id doesn't work then i used "common" CreateWindow with BUTTON as parametar and got a nice round button but my program wouldn't accept any further rightclicks (no context menu) this is my method wich creates squared flat button (i could create many buttons) void CpaintView::OnFalseCircle() { CPoint point; GetCursorPos(&point); ScreenToClient(&point); CButton *cir = new CButton(); cir->Create("tri",BS_FLAT, CRect(point,CPoint (point.x+20,point.y+20)),AfxGetMainWnd(),1); cir->ShowWindow(SW_SHOWNORMAL); } and non-working method wich creates one circle and stucks void CpaintView::OnCircle() { CPoint point; GetCursorPos(&point); ScreenToClient(&point); CRect rect(point, CPoint(point.x+50, point.y+50)); CRgn rgn; Circle *cr = new Circle(); rgn.CreateEllipticRgnIndirect(rect); SetWindowRgn(rgn,true); CreateWindow("BUTTON","",WS_CHILD | WS_VISIBLE, point.x-10,point.y- 10,70, 70, *this,(HMENU)101,0,0); } thanks

    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