-
June 9th, 2015, 08:08 PM
#1
Weird splitter issue
I borrowed a bit of code for a splitter bar in between two edits, but I'm getting weirdness when I try to either write on the bottom one or resize them by moving the bar. Often, the bottom edit disappears completely and the scrollbar dances around.
Ultimately, my goal is to have the window divided up into 5 different edits for a look similar to this:
Am I going about it the right way?
Relevant code:
HTML Code:
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HINSTANCE hInst;
RECT rect;
static HCURSOR hCursor;
static BOOL bSplitterMoving;
static DWORD dwSplitterPos;
static HWND hWnd1, hWnd2;
switch (uMsg)
{
case WM_CREATE:
{
hInst = ((LPCREATESTRUCT)lParam)->hInstance;
hWnd1 = CreateWindowEx(WS_EX_CLIENTEDGE,
L"edit", NULL,
WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL,
0, 0, 0, 0,
hWnd, (HMENU)1,
hInst, NULL);
hWnd2 = CreateWindowEx(WS_EX_CLIENTEDGE,
L"edit", NULL,
WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL,
0, 0, 0, 0,
hWnd, (HMENU)2,
hInst, NULL);
hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS));
bSplitterMoving = FALSE;
dwSplitterPos = 130;
HTML Code:
case WM_SIZE:
if ((wParam != SIZE_MINIMIZED) && (HIWORD(lParam) < dwSplitterPos))
dwSplitterPos = HIWORD(lParam) - 10;
/* Adjust the children's size and position */
MoveWindow(hWnd1, 0, 0, LOWORD(lParam), dwSplitterPos - 1, TRUE);
MoveWindow(hWnd2, 0, dwSplitterPos + 2, LOWORD(lParam), HIWORD(lParam) - dwSplitterPos - 2, TRUE);
return 0;
case WM_MOUSEMOVE:
if (HIWORD(lParam) > 10) // do not allow above this mark
{
SetCursor(hCursor);
if ((wParam == MK_LBUTTON) && bSplitterMoving)
{
GetClientRect(hWnd, &rect);
if (HIWORD(lParam) > rect.bottom)
return 0;
dwSplitterPos = HIWORD(lParam);
SendMessage(hWnd, WM_SIZE, 0, MAKELPARAM(rect.right, rect.bottom));
}
}
return 0;
case WM_LBUTTONDOWN:
SetCursor(hCursor);
bSplitterMoving = TRUE;
SetCapture(hWnd);
return 0;
case WM_LBUTTONUP:
ReleaseCapture();
bSplitterMoving = FALSE;
return 0;
Images showing what's happening:
http://imgur.com/a/OcdSx
-
June 10th, 2015, 03:16 AM
#2
Re: Weird splitter issue
1. Please, use CODE tags rather than HTML ones.
2. Please, attach your Images to your post.
3. You wrote about "5 different edits" however your picture shows only four and all of them are not "edits". Besides, in your code snippets there are only two children are created.
BTW, is your project a Win32 ( non-MFC) one or it is MFC one?
Victor Nijegorodov
-
June 10th, 2015, 10:27 AM
#3
Re: Weird splitter issue
Thanks for the response. I hit the wrong button for code, apologies.
I would like to keep this only Win32, no MFC. The "five different" comment is what I'd like to ultimately do, and the picture is what I want it to look like visually (i.e. placement of child windows). This was just the initial test to see if this worked as expected. I was then planning on adding the others later. But as it didn't work as expected, I'm wondering if this is the wrong way to go about it. I couldn't find a good picture of what I actually wanted, so it's an approximate. I figured I could just fiddle with the numbers, so long as the child windows didn't move like they're doing with this code.
Here are the images from Imgur (when I posted it first on StackOverflow, they didn't allow that many links):
-
June 10th, 2015, 10:44 AM
#4
Re: Weird splitter issue
Originally Posted by opwuaioc
I would like to keep this only Win32, no MFC.
Then I'd have a look at the existing splitter examples rather than reinvent the wheel.
How To Create Splitter Window With APIs?
Win32 splitter window project
Victor Nijegorodov
-
June 10th, 2015, 10:45 AM
#5
Re: Weird splitter issue
Victor Nijegorodov
-
June 10th, 2015, 12:41 PM
#6
Re: Weird splitter issue
Ha, I wasn't! I borrowed the code from this: http://old.sumitbirla.com/software/splitter.php
Still not sure what I'm doing wrong with this code, but I guess I'll move on and look at other examples.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|