[help] Windows widths and heights... - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4) +---- Forum: Scripting (/forumdisplay.php?fid=39) +----- Thread: [help] Windows widths and heights... (/showthread.php?tid=93453) [help] Windows widths and heights... by whiz on 01-06-2010 at 06:15 PM
I want to make a more visual method of creating windows in Interface Writer, and I need to know if I can get the width and height of a PlusWnd object. I'm guessing that I would need to register the WM_SIZE notification on the window, and also that I would need to use Interop, but what function? RE: [help] Windows widths and heights... by Mnjul on 01-06-2010 at 06:25 PM
You can also use MoveWindow instead of SetWindowPos. RE: [help] Windows widths and heights... by Spunky on 01-06-2010 at 06:26 PM
quote: I would imagine he would so that he could update the xml to reflect the new size RE: [help] Windows widths and heights... by Mnjul on 01-06-2010 at 06:28 PM
quote:Well, then, WM_SIZE is the way to go. Anyway its lParam encompasses the window dimension values so no need to GetWindowRect if you listen to WM_SIZE. RE: [help] Windows widths and heights... by whiz on 01-06-2010 at 06:33 PM
quote:Correct. I'm making a window designer that uses a blank window, with a title text box, minimize/maximize/close checkboxes and so on, as well as two text boxes that reflect the current size of the window. js code:The problem is... the lParam contains a single, long, number. How can I separate this into the width and height? Example: start size equates to "19661199". RE: [help] Windows widths and heights... by Matti on 01-06-2010 at 06:51 PM
quote:This is where bitwise operations come in handy. To get the low-order word, you need to get the first word from the number. A word is an unsigned number of 2 bytes or 16 bits. The maximum word value is thus 1111 1111 1111 1111 in binary or 65,535 in decimal or FFFF in hexadecimal. We can now use the & operator to do a bitwise AND operation. The AND operator takes two bits and returns 1 if both bits are 1, otherwise it gives 0. Applying this bit by bit on lParam and 0xFFFF, you'll get 0 for all bits further than bit 16 and bits 1 to 16 will give you the original bits from lParam in that position. This gives you the low-order word. js code:For the height, we need to get the other 16 bits. This can be done by shifting the bits of lParam 16 bit positions to the right using the bitwise right-shift operator >>. For example: bit 20 will be shifted to bit 4 for example and bits 1 to 16 will be discarded. This gives you the high-order word. js code:If you want to be really sure that you're only getting 16 bits, you can do an & 0xFFFF operation on the result to discard any bits after bit 32. This won't be necessary for WM_SIZE since Windows promises you to only give you 32 bits. Built-in operators are always lots faster than another call to GetWindowRect, so you better use them! RE: [help] Windows widths and heights... by whiz on 01-06-2010 at 07:09 PM
Ok, that works great! js code:But nothing happens. No error, just nothing. RE: [help] Windows widths and heights... by Spunky on 01-06-2010 at 07:15 PM
You need to pass the handle to WndTest, not the object, don't you? RE: [help] Windows widths and heights... by whiz on 01-06-2010 at 07:21 PM
True. Ok, but now I have another problem. js code:That's what I have so far. But by clicking the size button after typing in, say, 300x200, I end up with an infinitely sized window. Am I missing something? Edit: never mind, found it. Forgot parseInt(). Although, it doesn't actually size it right. 400x300 comes out as 394x268. How come? RE: [help] Windows widths and heights... by Spunky on 01-06-2010 at 07:26 PM
Have you tried Tracing the EdtWidth and EdtHeight values? I've got a feeling it might not be reading them right. Don't know, but it might have something to do with the type conversion, although I would have imagined it would convert to an integer ok. RE: [help] Windows widths and heights... by whiz on 01-06-2010 at 07:31 PM
Ok, I'm adding 6 to the width and 32 to the height, which counter-acts the borders. Seems to work great! RE: [help] Windows widths and heights... by Spunky on 01-06-2010 at 07:37 PM
RE: [help] Windows widths and heights... by whiz on 01-06-2010 at 07:55 PM
Looks a bit confusing... quote:I need to convert pixels to dialog units, not dialog units to pixels... RE: [help] Windows widths and heights... by Spunky on 01-06-2010 at 08:13 PM
I didn't check, but I thought maybe you could reverse the process? RE: [help] Windows widths and heights... by whiz on 01-06-2010 at 08:53 PM
That's what I've thought about doing. The user can always change it to dialog units if they want, but if they use the builder, then it'll have to be in pixels. RE: [help] Windows widths and heights... by T-PO on 01-06-2010 at 09:17 PM
Looks great! RE: [help] Windows widths and heights... by Eljay on 01-06-2010 at 09:31 PM
quote: It certainly should be possible. You would have to deal with drawing the rectangle yourself using GDI or whatever, but you would basically just have to handle mouse messages (WM_LBUTTONDOWN,WM_MOUSEMOVE,etc.) and redraw the rectangle each time. Unfortunately there's no magic control that does this for you that I know of, but it shouldn't be too hard to implement. RE: [help] Windows widths and heights... by whiz on 01-06-2010 at 09:49 PM Hmm... I'll have to think about it. For now, I need some sleep and preparation for exams. RE: [help] Windows widths and heights... (solved for now) by matty on 01-06-2010 at 11:10 PM
quote:Screenshot Sender has this capability for sending the Selected Area. Have a look at the code: http://beta.screenshotsender.com/code/WindowHandl...ectArea_handler.js And the Window: http://beta.screenshotsender.com/code/Languages/en/SelectArea.xml Cheers! RE: [help] Windows widths and heights... (solved for now) by whiz on 01-07-2010 at 02:04 PM
quote:I've had a look at the two files, but I'm not exactly sure how to implement it. How would I be able to draw a rectangle over a Plus! window, and get the left/top/width/height values in relation to that window? RE: [help] Windows widths and heights... (solved for now) by matty on 01-07-2010 at 04:00 PM
quote:Are you doing this so that you can create a control based on the part in which you are dragging? RE: [help] Windows widths and heights... (solved for now) by whiz on 01-07-2010 at 04:51 PM
quote:Yes, but I know I can't physically make it. I just need the co-ordinates. I want to be able to export the window of which the user selects to add a control to, and then open it, allowing them to draw where they want the control on their window. This would then open the Add Control window, with the co-ordinates set. |