473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

problem with resizing an Edit box

86
Expand|Select|Wrap|Line Numbers
  1.  
  2. HWND gEditBox;
  3.  
  4. int APIENTRY WinMain(....)
  5. {
  6. HWND hWnd; 
  7. ...
  8. ...
  9. ...
  10.  
  11. WNDCLASSEX wcex;
  12.  
  13. wcex.style = CS_HREDRAW | CS_VREDRAW;
  14. ..
  15. ..
  16. ..
  17. // Main Window
  18. hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
  19. ..
  20. .. 
  21. }
  22.  
  23.  
  24. LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  25. {
  26. switch(msg)
  27. case WM_CREATE:
  28.  
  29. RECT rect;
  30. GetClientRect(hWnd, &rect);
  31.  
  32. // Creating Edit Box 
  33. gEditBox = CreateWindow("EDIT", NULL, WS_CHILD | WS_HSCROLL |
  34. WS_VSCROLL | WS_VISIBLE | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_WANTRETURN | ES_MULTILINE | ES_LEFT | ES_NOHIDESEL, 0, 0, rect.right, rect.bottom, hWnd, (HMENU)IDC_TEXTPAD, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
  35.  
  36. beak;
  37.  
  38. case WM_COMMAND:
  39. wmId = LOWORD(wParam);
  40. wmEvent = HIWORD(wParam);
  41. switch(wmId)
  42. {
  43. ...
  44. ...
  45. ..
  46. }
  47. }
  48.  
  49.  
I have created an Edit box through Createwindow() as the WinProc recieves the WM_CREATE message
Now everything is working fine but except that when i maximise my parent window or resize it the edit box fails to do so though it is declared a child window.
How could i fix this?

if my problem is not understood should i post the entire code here for better analysis...
Sep 15 '07 #1
4 2292
Studlyami
464 Expert 256MB
I believe you have to handle the resize automatically. You can capture the WM_SIZE grab the rect of the main window then resize the edit box as needed.
Sep 15 '07 #2
ayan4u
86
I believe you have to handle the resize automatically. You can capture the WM_SIZE grab the rect of the main window then resize the edit box as needed.

well i tried that...

captured the WM_SIZE message and then used

DestroyWindow(gEditBox)

SendMessage(hWnd, WM_CREATE, 0, 0);

so that the edit box is created again but there an access violation is occuring in CreateWindow() i.e, when it is called through WM_SIZE

BTW a WM_SIZE message is also dispatched as soon as a window is created along with WM_CREATE so now i am using WM_SIZING
Sep 15 '07 #3
Studlyami
464 Expert 256MB
I wouldn't destroy the edit box on WM_SIZE; you just need to set the window position.

The way i would handle this is have a global variable that holds the old parent window rect. find how far it moves to the left and right and set the edit box to the left and right. To scale the size you need to know how much of the parent you want the edit box to take up. The example below uses 75% of the parent window.

Also in your WM_SIZE you will need to ensure that the EditBoxHandle != NULL before you call the ResizeEdit function.

EX:
Expand|Select|Wrap|Line Numbers
  1. RECT OldParentRect;
  2.  
  3. void ResizeEdit(hWnd)
  4. {
  5.    //hWnd = parent window
  6.     RECT TempRect;
  7.     GetWindowRect(hWnd, &TempRect);
  8.      int EditBoxPositionX += (TempRect.left-OldParentRect.left); 
  9.       int EditBoxPositionY += (TempRect.top-OldParentRect.top);
  10.      int EdbitBoxPositionXc = EditBoxPositionX + ((TempRect.right-TempRect.left) *.75);
  11.    int EdbitBoxPositionYc = EditBoxPositionY+ ((TempRect.bottom-TempRect.top) *.75);
  12.      SetWindowPos(EditBoxhWnd, EditBoxPositionX, EditBoxPositionY, EditBoxPositionXc,  EditBoxPositionYc,)
  13.    OldParentRect = TempRect;  //i think that needs the function copy rect don't remember.
  14. }
  15.  
Sep 15 '07 #4
ayan4u
86
I wouldn't destroy the edit box on WM_SIZE; you just need to set the window position.

The way i would handle this is have a global variable that holds the old parent window rect. find how far it moves to the left and right and set the edit box to the left and right. To scale the size you need to know how much of the parent you want the edit box to take up. The example below uses 75% of the parent window.

Also in your WM_SIZE you will need to ensure that the EditBoxHandle != NULL before you call the ResizeEdit function.

EX:
Expand|Select|Wrap|Line Numbers
  1. RECT OldParentRect;
  2.  
  3. void ResizeEdit(hWnd)
  4. {
  5. //hWnd = parent window
  6. RECT TempRect;
  7. GetWindowRect(hWnd, &TempRect);
  8. int EditBoxPositionX += (TempRect.left-OldParentRect.left); 
  9. int EditBoxPositionY += (TempRect.top-OldParentRect.top);
  10. int EdbitBoxPositionXc = EditBoxPositionX + ((TempRect.right-TempRect.left) *.75);
  11. int EdbitBoxPositionYc = EditBoxPositionY+ ((TempRect.bottom-TempRect.top) *.75);
  12. SetWindowPos(EditBoxhWnd, EditBoxPositionX, EditBoxPositionY, EditBoxPositionXc, EditBoxPositionYc,)
  13. OldParentRect = TempRect; //i think that needs the function copy rect don't remember.
  14. }
  15.  

hmmm thanks a lot...i will try to implement that....but wonder wht creating a new edit window afresh is not working....though this technique is very bad as i must admit...neways thanx a lot again
Sep 15 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Alex Hopson | last post by:
I'm using the code below to loop through some images and resize each image twice, once to create a thumbnail and once to create a small image. The page stops loading around the 38th image out of...
10
by: riki | last post by:
Hi, i have a big problem...i'm using one jscript for resizing of all of my pics in popUp...in main html i'm having many little pics and clicking on them they open in popUp and resize to larger...
8
by: Freek te Water | last post by:
Hi, Hope no-one is offended by my probably noob question... Context: I have a web page design, which always centres in the middle of the screen (using a 100%*100% HTML-table). Now I also use...
4
by: Mimo Zus | last post by:
I'm hoping that someone can explain what's going on; better yet provide a workaround. I'm designing a centered CSS site based on a 550 pixel wide vertical background image. Onto this background...
3
by: eft0 | last post by:
I have a big problem after I install SP2 in XP Box, some functions - window.resizeBy() - in my code, give a error like this: Access Denied. Some similar experience ?, any ideas what's...
3
by: James Spibey | last post by:
Hi, I have an MDI application which has aboout 10 child windows. The way the app needs to work is that only one window should be visible at a time and it should be maximized within the parent...
11
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to...
4
by: Alan Silver | last post by:
Hello, If you add (say) two text boxes to a form, then add a validator with some simple rule for one of them, you can observer the following problem:- Type some erroneous value in the text...
7
by: aaronic | last post by:
This is in reference to my previos post but a completely different problem. Previous problem and code can be found here: http://www.thescripts.com/forum/thread563724.html When I run the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.