-
-
HWND gEditBox;
-
-
int APIENTRY WinMain(....)
-
{
-
HWND hWnd;
-
...
-
...
-
...
-
-
WNDCLASSEX wcex;
-
-
wcex.style = CS_HREDRAW | CS_VREDRAW;
-
..
-
..
-
..
-
// Main Window
-
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
-
..
-
..
-
}
-
-
-
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
-
{
-
switch(msg)
-
{
-
case WM_CREATE:
-
-
RECT rect;
-
GetClientRect(hWnd, &rect);
-
-
// Creating Edit Box
-
gEditBox = CreateWindow("EDIT", NULL, WS_CHILD | WS_HSCROLL |
-
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);
-
-
beak;
-
-
case WM_COMMAND:
-
wmId = LOWORD(wParam);
-
wmEvent = HIWORD(wParam);
-
switch(wmId)
-
{
-
...
-
...
-
..
-
}
-
}
-
-
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...
4 2292
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.
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
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: -
RECT OldParentRect;
-
-
void ResizeEdit(hWnd)
-
{
-
//hWnd = parent window
-
RECT TempRect;
-
GetWindowRect(hWnd, &TempRect);
-
int EditBoxPositionX += (TempRect.left-OldParentRect.left);
-
int EditBoxPositionY += (TempRect.top-OldParentRect.top);
-
int EdbitBoxPositionXc = EditBoxPositionX + ((TempRect.right-TempRect.left) *.75);
-
int EdbitBoxPositionYc = EditBoxPositionY+ ((TempRect.bottom-TempRect.top) *.75);
-
SetWindowPos(EditBoxhWnd, EditBoxPositionX, EditBoxPositionY, EditBoxPositionXc, EditBoxPositionYc,)
-
OldParentRect = TempRect; //i think that needs the function copy rect don't remember.
-
}
-
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: -
RECT OldParentRect;
-
-
void ResizeEdit(hWnd)
-
{
-
//hWnd = parent window
-
RECT TempRect;
-
GetWindowRect(hWnd, &TempRect);
-
int EditBoxPositionX += (TempRect.left-OldParentRect.left);
-
int EditBoxPositionY += (TempRect.top-OldParentRect.top);
-
int EdbitBoxPositionXc = EditBoxPositionX + ((TempRect.right-TempRect.left) *.75);
-
int EdbitBoxPositionYc = EditBoxPositionY+ ((TempRect.bottom-TempRect.top) *.75);
-
SetWindowPos(EditBoxhWnd, EditBoxPositionX, EditBoxPositionY, EditBoxPositionXc, EditBoxPositionYc,)
-
OldParentRect = TempRect; //i think that needs the function copy rect don't remember.
-
}
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
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
|
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...
|
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...
| |