|
Sure - catch the event when your window resizes, and call SetWindowPos on the button. The last parameter you want in SWP_NOZORDER, as you don't want to change that.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
See Here[^]. I just did it for an edit window. You can do similarly for a button.
you can also handle the WM_SIZE message.
What is the type of application that you are working on?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
my requirement is like this.. i have to simulate a buton which can be moved as well as resizable. It shud not get a feeling like its enclosed in a dlg.
|
|
|
|
|
SKMukherjee wrote: i have to simulate a buton which can be moved as well as resizable.
Handle WM_SIZE message in your window, the handler function will have two int parameters which has the window width (cx) and window height (cy). Say you have control variable for your Button (like, m_myButton), use it to resize your button as,
m_myButton.MoveWindow(0, 0, cx, cy)
or
m_myButton.SetWindowPos(&wndTop, 0, 0, cx, cy, SWP_NOZORDER)
Hope this will help you...
Do your Duty and Don't expect the Result
|
|
|
|
|
SKMukherjee wrote: My problem is if i resize the window, the size of the button also shud resize so as to fit the parent rect. Is it possible?
See the Extras section of this article.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
HI,
My application MDI application,i have different views,
when i click one option(example:go to page1) then it has display that particular page1.
It displays as it is...but it repaint on the old page and displayed..but i have to get the new page as a seperate window(like pop up) with resizing bar..like that..Pls help me out?
-- modified at 6:33 Thursday 28th September, 2006
Anu
|
|
|
|
|
Im sorry but I dont understand what you say?
|
|
|
|
|
Hi,
I'm having some problem with SendMessage/PostMessage API simulating a "click" on the [SAVE] button on IE's Download Dialog Box. Would appreaciate any sort of suggestions. Thanks
Scenario:
Clicking on a hyperlink (link to a file, e.g Try.xls) in Internet Explorer. A Dialog appear with 3 options, [Open],[Save],[Cancel]
Code Snippets:
BOOL bResult = FALSE;
HWND MainDialog = NULL, SaveButton = NULL;
MainDialog = FindWindow(NULL,"File Download");
if (MainDialog == NULL)
printf("Cannot Find Main Save DialogBox.\n");
else
{
SaveButton = FindWindowEx(MainDialog, NULL, NULL, "&Save");
if (SaveButton == NULL)
{
printf("Cannot Find Save Button.\n");
exit(0);
}
else
{
SetFocus(SaveButton);
bResult = PostMessage(SaveButton, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(0,0));
if (!bResult) exit(0);
bResult = PostMessage(SaveButton, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(0,0));
if (!bResult) exit(0);
}
}
Problems:
When I'm stepping through this step: PostMessage(SaveButton, WM_LBUTTONDOWN.. , I can see the button in depressed mode, and the Focus has been changed to the [Save] Button. But on Buttonup, nothing happens.
Tested Method (But I might have done it wrongly):
1. Have tried SendDlgItemMessage API and using GetDlgCtrlID to get the ControlID of the [Save] Button (Have verified using Spy++, and they are same). But it doesn't work.
2. Tried to send TAB key to the DialogBox, and the focus shift to [SAVE] button. But sending "Space" keystroke to the dialog also have no effect. (Can see the button moving, but nothing happens after that)
4. Tried changing the Default button from [CANCEL] to [SAVE] and sending SPACE KEY. Doesnt work.
-- PostMessage(MainDialog, (UINT) DM_SETDEFID, (WPARAM) GetDlgCtrlID(SaveButton) , TRUE);
3. On the other hand, when I try to activate the [Cancel] button, it works correctly.
Findings: (using Spy++)
1. I noticed that the [CANCEL] button has a ControlID of 000002, whereas the [OPEN] button and [SAVE] button has ControlID of 00001147 and 00001148 respectively. This probably means that [OPEN] and [SAVE] are not "default buttons". Therefore using VBScript, I tried - Msgbox "HelloCodeProject",vbYesNoCancel. [YES] button has ControlID of 6, [NO] had ControlID of 7 and [CANCEL] had Control ID of 2.
Apart from IE's Download Dialog Box, there are several other application that cannot be controlled using the SendMessage. Would appreciate any sort of suggestion.
By the way, using VBScript AppActivate, and SendKeys method is able to successfully activate the [SAVE] button, but that's not the way I want.
|
|
|
|
|
Have you tried sending the button a BM_CLICK message? What about using SendInput() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Good day Mr David,
I have tried BM_CLICK. But still it doesn't work.
As for SendInput, I understand from the API that it inserts events into the keyboard or mouse input stream. This probably means that if the focus is changed from the [SAVE] dialog box to other program, it might not work because at the same time, a few other automation tools will be running as well. This is why the WShell AppActivate and SendKeys function would not work when the focus is changed to other program.
Nonethelss, I would still try it out.
And thanks for the suggestions.
Would appreaciate more suggestions. Thanks you.
|
|
|
|
|
Hi All,
I want to know if there is anyway i can get call stack information.
say i have a pointer(address) to a class object. is there anyway i can access stack info using the pointer, which gives me the place this pointer was created?
Please kinldly help me. any help would be greatly appreciated.
Thanks in advance.
Thanks & Regards,
Dhana
|
|
|
|
|
The place the pointer was created has nothing to do with the stack.
VS actually tracks your pointers, if you leak one, it will show you where it thinks you created it ( in debug mode ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: The place the pointer was created has nothing to do with the stack.
now graus isnt this a little outrageous statement...
the pointer itself is normally defined on stack ... but i agree there is nothing useful you can get from that pointer.. anyways there are some debugging api's available like google "Win32 Debug API" u'll get a lot links
cheers...
|
|
|
|
|
Ooops - brain freeze moment, I thought he was looking for the call stack. Dumb, dumb, dumb.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
now i may be wrong here! but aint the call stack the same stack where all the stack frame variables are defined???? As far as i know the call stack is just the snapshot of the return address of the called functions?? ain't it so?
|
|
|
|
|
On x86 platforms the stack contains the following:
- Return addresses.
- Function parameters.
- Local variables.
- Registers pushed on the stack (and later popped to restore them).
- SEH information.
Steve
|
|
|
|
|
good morning
CTreeEditorView is a CView in which we create the treeView
To let the tree control occupy all the space of the client area :
void CTreeEditorView::OnSize(UINT nType, int cx, int cy)
{
CRect r;
GetClientRect(&r);
m_etc.MoveWindow(r);
}
but if I want that it occupied the left side of the client area how this code must be modified
|
|
|
|
|
adjust the rect members to better define an area you want the tree view to be displayed
|
|
|
|
|
You can set location of treeview with MoveWindow and new size now what problem?
|
|
|
|
|
I tried this but it doesn't work
CRect r(20,20,120,120);
GetClientRect(&r);
m_etc.MoveWindow(r);
|
|
|
|
|
No its not true when you use GetClientRect it gets coordinate and fill a RECT structure but when you want to use new rect like your message you dont need to use GetClientRect.
<br />
CRect r(20,20,120,120); <br />
m_etc.MoveWindow(r);
|
|
|
|
|
Hi all,
I would like to create single document interface something like notepad. Now my problem is i created the basic display. but in the display i couldnt see the cursor and if i enter anything in the keyboard, the display will not show that character.
Can you please tell me some ideas or refer me some articles?
Thanks in advance.
Regards,
Ram
|
|
|
|
|
Ram Murali wrote: Now my problem is i created the basic display
Did you create an Edit/Richedit control on your window?
Ram Murali wrote: the display will not show that character.
It's the window of the application that you create.
You would need a richedit control or an edit box to start typing the text as we do it in notepad.
Here's the code for you:
In your Window Procedure you can create two variables as follows:
<br />
static HWND hWndEdit;<br />
static POINT pt;<br />
In the WM_CREATE message:OnCreate() of SDI Application.
<br />
hWndEdit =CreateWindow("EDIT","",WS_CHILD|WS_VISIBLE|WS_BORDER,<br />
0,0,pt.x,pt.y,m_hWnd,NULL,<br />
GetModuleHandle(NULL),0);<br />
in WM_SIZE: (OnSize() of the SDI Application)
<br />
pt.x=LOWORD(lParam);
pt.y =HIWORD(lParam);
MoveWindow (hWndEdit,0,0,pt.x,pt.y,true);<br />
This is for WIN32 application. You can apply the same logic for MFC Application.
And now you can compile and run the application and type something in the window that we just created.
I hope this helps.
-- modified at 4:24 Thursday 28th September, 2006
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I didnt create anything. I jus followed the MFC wizard to create a single document interface. thatsall. after that i didnt do anything. the output of my design is same as NOTEPAD, But i dont get the blinking cursor and if i press any key in the keyboard, its not displayed in the Notepad text area.
( I am trying to create a application same as notepad in window).
Regards,
Ram
|
|
|
|
|
I have provided a basic logic. You can build on this. You can also take a rich edit control instead of the edit window as I do.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|