line thinkness
-
Could you please post the relevant code? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]int paint_line(HWND hwnd, HDC hdc, int x0, int y0, int x9, int y9, int thickness, COLORREF rgb) { HBRUSH hbr; HPEN hpen, hpen_sav; hpen = CreatePen(PS_SOLID, thickness, rgb); hpen_sav = (HPEN) SelectObject(hdc, hpen); hbr = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH)); MoveToEx(hdc, x0, y0, NULL); LineTo(hdc, x9, y9); DeleteObject(SelectObject(hdc, hbr)); SelectObject(hdc, hpen_sav); DeleteObject(hpen); return 0; }
-
I am using pen to plot lines in graph hpen = CreatePen(PS_SOLID, thickness, rgb); even after giving the thinkness parameter as 5 . thickness of the line still remain same as if we put zero... is there any thing i m missing to add or any code or api to increase thickness of the line pls help me to come out of this mess thanks in advance............
Are you completely sure your
thickness
parameter's value isn't 0 or 1 when you call yourpaint_line
function? Aside of that i believe what line widths and styles you can use depends on the driver "behind" the DC, are you maybe drawing onto some "special" target, like a PDF writer or -dunno- a plotter machine's printer driver or somesuch?> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
-
int paint_line(HWND hwnd, HDC hdc, int x0, int y0, int x9, int y9, int thickness, COLORREF rgb) { HBRUSH hbr; HPEN hpen, hpen_sav; hpen = CreatePen(PS_SOLID, thickness, rgb); hpen_sav = (HPEN) SelectObject(hdc, hpen); hbr = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH)); MoveToEx(hdc, x0, y0, NULL); LineTo(hdc, x9, y9); DeleteObject(SelectObject(hdc, hbr)); SelectObject(hdc, hpen_sav); DeleteObject(hpen); return 0; }
Your code is fine, I called it this way:
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
paint_line(hWnd, hdc, 0, 0, 400, 400, 5, RGB(255,0,0));
EndPaint(hWnd, &ps);
break;and got a beautiful red thick line in my window. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
int paint_line(HWND hwnd, HDC hdc, int x0, int y0, int x9, int y9, int thickness, COLORREF rgb) { HBRUSH hbr; HPEN hpen, hpen_sav; hpen = CreatePen(PS_SOLID, thickness, rgb); hpen_sav = (HPEN) SelectObject(hdc, hpen); hbr = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH)); MoveToEx(hdc, x0, y0, NULL); LineTo(hdc, x9, y9); DeleteObject(SelectObject(hdc, hbr)); SelectObject(hdc, hpen_sav); DeleteObject(hpen); return 0; }
Have you set any mapping mode at the DC ? :) (did you tried with thickness = 100 ?)
virtual void BeHappy() = 0;
-
Are you completely sure your
thickness
parameter's value isn't 0 or 1 when you call yourpaint_line
function? Aside of that i believe what line widths and styles you can use depends on the driver "behind" the DC, are you maybe drawing onto some "special" target, like a PDF writer or -dunno- a plotter machine's printer driver or somesuch?> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
-
Have you set any mapping mode at the DC ? :) (did you tried with thickness = 100 ?)
virtual void BeHappy() = 0;
-
Could you post your calling context of the function too ? :) (it is a function that does call the
paint_line(..)
function)virtual void BeHappy() = 0;
-
thanks for the reply I have tried from 0 to 50... :( but no change in the thickness.... i m plotting line in Wingdi normal graph
Use the debugger to trace through your function to see what exact value is being passed in the
thickness
parameter. It is likely that you are not passing this parameter correctly.txtspeak is the realm of 9 year old children, not developers. Christian Graus
-
thanks for the reply I have tried from 0 to 50... :( but no change in the thickness.... i m plotting line in Wingdi normal graph
Place a breakpoint on the beginning of your
paint_line
method and once it gets hit, check thethickness
parameter's value to see if it really is not 0 or 1.> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
-
Your code is fine, I called it this way:
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
paint_line(hWnd, hdc, 0, 0, 400, 400, 5, RGB(255,0,0));
EndPaint(hWnd, &ps);
break;and got a beautiful red thick line in my window. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]I m working on a maintanance project which is too big. the same code which i send to you is been used in my project but its not working .is there any possiblity to set some default thickness of lines throughout the graph.i scare that like that some handling has been done .. because i even tried till 50...
-
Could you post your calling context of the function too ? :) (it is a function that does call the
paint_line(..)
function)virtual void BeHappy() = 0;
-
inside paint line this is the portion where i create a pen hpen = CreatePen(PS_SOLID, thickness, rgb); i have tried like giving hpen = CreatePen(PS_SOLID, 0, rgb); . . . . . . . . . . . hpen = CreatePen(PS_SOLID, 50, rgb);
OK, could you try with
300
only, please ? :)virtual void BeHappy() = 0;
-
Place a breakpoint on the beginning of your
paint_line
method and once it gets hit, check thethickness
parameter's value to see if it really is not 0 or 1.> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
-
Your code is fine, I called it this way:
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
paint_line(hWnd, hdc, 0, 0, 400, 400, 5, RGB(255,0,0));
EndPaint(hWnd, &ps);
break;and got a beautiful red thick line in my window. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
OK, could you try with
300
only, please ? :)virtual void BeHappy() = 0;
-
Place a breakpoint on the beginning of your
paint_line
method and once it gets hit, check thethickness
parameter's value to see if it really is not 0 or 1.> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
-
No probs, here[^] you can find info about the mapping modes as mentioned by someone, try setting the MM_TEXT mapping mode before drawing your line and see what results that produces.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <
-
Probably a special DC Mapping Mode[^] was set in the calling context... :) (For example: Carlo Pallini has given his calling context - there are no modifications of the DC Mapping Mode there, so it is possible to "feel" the arguments by
2
or5
too :) )virtual void BeHappy() = 0;
-
Probably a special DC Mapping Mode[^] was set in the calling context... :) (For example: Carlo Pallini has given his calling context - there are no modifications of the DC Mapping Mode there, so it is possible to "feel" the arguments by
2
or5
too :) )virtual void BeHappy() = 0;
-
No probs, here[^] you can find info about the mapping modes as mentioned by someone, try setting the MM_TEXT mapping mode before drawing your line and see what results that produces.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <