954,487 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to draw this line?

I have a question to drow a line in GUI programming. I hope you could help me:)

In fact, it's not a continuous line, it's a line with break. The function I use to draw this line is like this:

Void DrawBreakLine(int nStartPoint, int nEndPoint, BYTE bPattern)

the last parameter bPattern tells the function how to break. If the corresponding bit is

1, draw a point, otherwise leave a space.


Example: bPattern = 0xf0

the line looks like this:

---- ---- ---- ---- ---- ----

4 points, 4 spaces


In fact, I can define a BYTE array and send to the function

Ex: BYTE bPattern[] = {0xff, 0x0};

the line looks like this:

-------- -------- -------- --------

8 points, 8 spaces

However, if your parameter is bPattern more than 2 bytes, the bytes after the 2nd

byte mean nothing.


Well, now I want to draw this line:

------------ ------------ ------------ ------------

as you can see, it's 12 points and 12 spaces.




How can I draw this line with DrawBreakLine function easily?




Thanks very much:)

kinggarden
Newbie Poster
16 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

>>How can I draw this line with DrawBreakLine func
did you try calling the function twice -- first time with {0xff,0xff} and the second time with {0x00,0x00} ? If that doesn't work then it probably can't do what you want it to without modifying the function.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

I hope you do realize that a byte consists of 8 bits. If all your program does is looks at the bit pattern and prints out dashes and spaces, you would either have to change the function signature to accept integers so that you can work with 32 bit patters or come up with a weird hack to get around this limitation.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

And your compiler should produce an error if you attempt to pass more than one byte as that parameter

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
>>How can I draw this line with DrawBreakLine func did you try calling the function twice -- first time with {0xff,0xff} and the second time with {0x00,0x00} ? If that doesn't work then it probably can't do what you want it to without modifying the function.



Thanks.

But if I do what you tell me, I think I will get nothing, right?

The first time I get a continuous line, while the second time

I get a set of spaces, and the line would be replaced by the

spaces. Right? :)

kinggarden
Newbie Poster
16 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 
I hope you do realize that a byte consists of 8 bits. If all your program does is looks at the bit pattern and prints out dashes and spaces, you would either have to change the function signature to accept integers so that you can work with 32 bit patters or come up with a weird hack to get around this limitation.



:) Yeah, I really know a byte is made up with 8 bits. However, I can't

change the function. What I know is that I have a function named

this, nothing more than you. If I could sovle this problem in a little

piece of codes, it would be great. Otherwise, I have to give up doing

this:)

kinggarden
Newbie Poster
16 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Maybe posting some code of the function would help us in helping you out.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 
Maybe posting some code of the function would help us in helping you out.



Acturally, I don't have the source code of this function. But if

someone is familiar with asm code, I would like to post some

codes:)

kinggarden
Newbie Poster
16 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You