|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Question about rectsI have a question which is driving me insane. I am not sure if I do this correctly: 1. I have a usercontrol (scalemode = pixel). 2. I get the rect by GetClientRect(usercontrol.hwnd,rWork) 3. Now I want to let this rect have 2 "cells", one on the left side of the rect, the other one on the right. I am having problems with determining the correct rects for the two cells within the rWork rect. I am absolutely not sure if this is correct. I am experiencing some pixel offsets, and I did not yet found out what's the problem. I would like to make sure that I did this code correctly. Thank you very much for any comment. iWidth = ((rWork.Right - rWork.Left) \ m_iColCount) iHeight = ((rWork.Bottom - rWork.Top) \ m_iRowCount) For r = 1 To m_iRowCount For c = 1 To m_iColCount cCell(r, c).Left = (iWidth * (c - 1)) cCell(r, c).Top = (iHeight * (r - 1)) cCell(r, c).Bottom = (iHeight * (r - 1)) + iHeight cCell(r, c).Right = (iWidth * (c - 1)) + iWidth Next c Next r "John Stulle" <j.stulleNOSPAM@googlemail.com> wrote Have you debugged the code?> I have a question which is driving me insane. > I am not sure if I do this correctly: > I would like to make sure that I did this code correctly. Print out your results and see....> cCell(r, c).Bottom = (iHeight * (r - 1)) + iHeight Only you know what the desired result actually is. If you want the> cCell(r, c).Right = (iWidth * (c - 1)) + iWidth cells to overlap by one pixel, then you can use what you have. If you don't want the cells to overlap then use something more like this: cCell(R, C).Bottom = cCell(R, C).Top + iHeight - 1 cCell(R, C).Right = cCell(R, C).Left + iWidth - 1 You might also consider something like this: For Row = 1 To m_iRowCount For Col = 1 To m_iColCount SetRect cCell(Row, Col), L, T, L + iWidth - 1, T + iHeight - 1 L = L + iWidth Next Col L = 0 T = T + iHeight Next Row HTH LFS |
|||||||||||||||||||||||