MOuse over in a specific area..

hey,
Now i want to draw a fig in my window..wao ya that is not difficult task...but i want to creat a function when mouse come over that specific fig. it change its color...

how can it possible....?

thanx...
Innocent boy

Comments

  • You would have to do a hit test on the mouse position in a WM_MOUSEMOVE event to trap the location of the pointer and then test to see if it is where you need it to be.
    [hr]
    Oh my god
    I can't deny this
    I've been taught just to kill and fight this
    To bury it deeper where nobody can find it
    Like nobody wanted to know
    -- Oh My God - Guns N' Roses

  • hey,

    MoveToEx(hdc,300,50,NULL);// this moves the cursor to require position
    LineTo(hdc,220,250);
    MoveToEx(hdc,300,50,NULL);
    LineTo(hdc,380,250);
    LineTo(hdc,180,125);
    LineTo(hdc,415,125);
    LineTo(hdc,220,250);

    i used this lines to draw a star... in the mid of window.. now i want to fill start with color...how can i do this...
    or is there any other technique by which i can make a star..

    thanx..

  • : hey,
    :
    : MoveToEx(hdc,300,50,NULL);// this moves the cursor to require position
    : LineTo(hdc,220,250);
    : MoveToEx(hdc,300,50,NULL);
    : LineTo(hdc,380,250);
    : LineTo(hdc,180,125);
    : LineTo(hdc,415,125);
    : LineTo(hdc,220,250);
    :
    : i used this lines to draw a star... in the mid of window.. now i want to fill start with color...how can i do this...
    : or is there any other technique by which i can make a star..
    :
    : thanx..
    :
    :
    [blue]Well, you certainly picked not a very simple coding example, because to use a rectangle would have been a little easier. Windows has a term: [italic]region[/italic]. Once you create a region - you can fill it with color or draw a frame around it or check if point lies inside the region. Region can be a very complex shape. Check the region API here:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/functions_by_category.asp

    Click on [b]Region[/b]...[/blue]
  • Or a path:
    [code]
    [blue]
    BeginPath(hdc);
    [/blue]
    // draw your star
    MoveToEx(hdc,300,50,NULL);// this moves the cursor to require position
    LineTo(hdc,220,250);
    MoveToEx(hdc,300,50,NULL);
    LineTo(hdc,380,250);
    LineTo(hdc,180,125);
    LineTo(hdc,415,125);
    LineTo(hdc,220,250);
    [blue]
    EndPath(hdc);

    // fill with red
    HBRUSH brush = CreateSolidBrush(RGB(255, 0, 0));
    HBRUSH oldBrush = (HBRUSH)SelectObject(hdc, brush);
    SetPolyFillMode(hdc, WINDING);
    FillPath(hdc);
    SelectObject(hdc, oldBrush);
    DeleteObject(brush);

    // dont forget to end the path
    AbortPath(hdc);
    [/blue]
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories