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:)

>>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.

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.

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

>>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? :)

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:)

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

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:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.