|
waldermort wrote: Why is MFC forced upon us?
It's not. That's what the developers themselves have chosen to use, hence the count of MFC examples likely outnumbers the count of Win32 examples.
I have an MFC example of this here. It uses GetClientRect() , GetWindowRect() , ScreenToClient() , OffsetRect() , and MoveWindow() .
waldermort wrote: GetWindowRect(hwnd,&rNewMain); // store the origional size // prevent resizing less than this
Call GetClientRect() in response to the WM_INITDIALOG message.
waldermort wrote: // set the smallest size bool resize = false; if (width < minW) { resize = true; width = minW; } if (height < minH) { resize = true; height = minH; } if (resize) { SetWindowPos(hwnd,NULL,0,0,width,height,SWP_NOZORDER | SWP_NOMOVE); return; }
You'll also want to handle the WM_GETMINMAXINFO message. Here is where you'd take care of the dialog's minimum size.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Thanks for pointing out the WM_GETMINMAXINFO, I have changed my code accordingly. Regarding my dissapearing windows, I am lost and confused. I changed the code to do some debugging:
SetWindowPos(hComment,NULL,
0,
0,
(rComment.right - rComment.left) + changeW,
(rComment.bottom - rComment.top),
SWP_NOZORDER | SWP_NOOWNERZORDER);
Setting a breakpoint on the above gives some strange results.
On the first break:
rComment.top == 540;
rComment.left == 113;
The above function should should now set them to 0 should it not? But on the following breaks:
rComment.top == 146;
rComment.left == 87;
I cannot understand why this is happening? This is the only part of the program that could possibly change these values, yet it is not being done as I want it to.
|
|
|
|
|
I think you are mixing up two issues.
1. The WM_SIZE is called repeatedly. Eahc time you get a window rectangle, it is not its ORIGINAL size you obtain but its most RECENT size. This is the same for the controls.
2. Your calculations must be based upon some ORIGINAL rectangle, which you can store somewhere, or abolute 'relative' calculations with resonable adjustments, like 'this contol is always from top to halfway down window', or 'this control is always 10 pixels high starting at bottom of window but always as wide as window'.
A quick glance at your code seems to use CURRENT control locations with some adjustments, so over time, they will 'float' to incorrect positions.
When hand-coding dynamic control layout, I usually favor using a relative position type algorithm to determine the location of each control. Some may be relative to each other, some may be relative to the window's new size.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Well I figured out the problem, but I haven't found the solution yet. But for anybody else having the same problem:
GetClientRect()
gets the client rectangle (0,0,width-border,height-border) which is your dialog window
GetWindowRect() // passing hwnd of dialog
gets the position and size of the dialog window relative to the screen (x-pos,y-pos,width,height);
GetWindowRect() // passing hwnd of control
gets the pos and size of control, relative to the screen and not the dialog!
SetWindowPos()
expects co-ordinates relative to the client area.
My confusing value of 87 in tha above code was coming from the x-pos of the dialog window (83) plus the width of the dialog border (4). In the world of MFC there is a function ScreenToClient(which will convert the rect), but in Win32 it doesn't quite work the same. You would have to convert your rects using some other method.
But here is the best solution: http://www.codeproject.com/dialog/dlgresizearticle.asp[^] This simple class has proved invaluable, I'm sure I will be using it in most of my future projects. Thanks go to the author
|
|
|
|
|
I would suppose in Win32 code you would do the following
void CWnd::ScreenToClient(LPRECT lpRect) const<br />
{<br />
ASSERT(::IsWindow(m_hWnd));<br />
::ScreenToClient(m_hWnd, (LPPOINT)lpRect);<br />
::ScreenToClient(m_hWnd, ((LPPOINT)lpRect)+1);<br />
if (GetExStyle() & WS_EX_LAYOUTRTL)<br />
CRect::SwapLeftRight(lpRect);<br />
}
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
waldermort wrote: In the world of MFC there is a function ScreenToClient(which will convert the rect), but in Win32 it doesn't quite work the same.
Right. CWnd::ScreenToClient() makes two calls to ::ScreenToClient() . This is what that article is doing, too. That appears to be the biggest difference from how the one I referenced works (aside from it being MFC).
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
LPTSTR ch1;
LPSTR ch2
LPTSTR A(LPTSTR p);
if project Character is ASNI, not wrong,
but if project Character is UNICODE, wrong, how to fix?
and what about if MBCS Character ?
|
|
|
|
|
|
|
I need some libs - code in order to convert a jpg image into a 2d matrix for my medical software. if anyone knows something or have a link to download the code please help me. Thanks for all
SPik
|
|
|
|
|
|
another nice library is cximage[^] which can not only read jpg but many other common images files as well.
-Saurabh
|
|
|
|
|
thanks for all. you save my life
SPik
|
|
|
|
|
|
i'm new to this platform.am a student.need to create a dialog based library system to search for a book,add,delete,and display all from adatabase without creating a dsn.that's the last point i'm stuck on plz help
|
|
|
|
|
RAVISHBHAMBORE wrote: ...without creating a dsn.
There is an example here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi,
had raised a querry for this yesterday, though dint ne good ideas, so thought would share some info I found after trying out all possible things...
To create a dynamicly increasing array of objects, that is the arraysize should increase dynamically. You can follow the below steps in .NET environ
1. Create an arraylist eg
ArrayList arrayObj = new ArrayList();
2. Add the objects in arrayObj
arrayObj.Add( obj1, obj2.... );
3. Copy this arraylist to an object array of the specific class as under
ClassA[] obj1 = new ClassA[arrayObj.Count];
arrayObj.CopyTo( obj1, 0 );
Now obj1 is an array of objects of type ClassA !
Cheers!
|
|
|
|
|
damn !!!
you never said you were working for .NET !
simply because you asked this on Visual C++ forum, you got C++ answers.
if you wanted MC++ (Managed C++) code, then you should have asked this in the C++/CLI forum[^], which is dedicated to the new Managed C++ Visual C++ compiler mode...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.24][3.0 soon...]
|
|
|
|
|
toxcct wrote: you never said you were working for .NET !
Geez, was so used to this forum! was the first time was workin on .NET! dint think of checking the CLI forum...and landed up in "apna" VC++ forum!
But hey look at the bright side, all got to know some .NET info as well eh!
If my query caused some brainknocking...sorry for that!
though this forum has always helped me!!!
Thanx!
|
|
|
|
|
I'm not seeing the correlation between the question and the answer. The code snippet that you've provided does not look like "a dynamicly increasing array of objects." It looks like one object array being copied to another. Could you not have just used std::array for this? It allows for dynamically growing/shrinking of the array.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: I'm not seeing the correlation between the question and the answer
actually, the question was there[^] (asked yesterday), and shown off his solution there...
and visibly, he wanted to use .net framework, which he never specified...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.24][3.0 soon...]
|
|
|
|
|
Hi,
I want to paint some overlay graphics upon a game screen (the game works with directx). I've tried to paint directly in the game HDC, but there's a lot of blinking because the game constantly paints upon my drawing (and viceversa).
How could I paint to eliminate the blinking? Would I have to use directx?
Any help will be highly appreciated.
-- modified at 6:58 Friday 24th February, 2006
|
|
|
|
|
Do all printing into a bitmap. When the picture is complete copy the bitmap (or parts of it) to the screen. That gets rid of al the blinking.
I might be able to give you some code, depending on what kind of class you are printing into.
|
|
|
|
|
hello all,
i have created an activex control in vc++ 6.O.It is a player.it will run .cam (video files).i tried to run this activex control in IE by copying its DLL.
It is running the video.but my problem is ,while moving the scroll bars (both horizontal & vertical scroll ) in the Internet explorer,the player stops playing and it is showing "Internet Exporer has encountered a problem with add-ons) and it closes the page.
I cant able to proceed further
Plz help me to resolve the problem.I will be very much thankful to u.
cheers
sangeet
|
|
|
|
|
You could run IE using the debugger. In project settings, in the Debug tab, it says "Executable for debug sessions" . Just enter the path for iexplore.exe , and then you can find the problem using the debugger.
I think it could be like repositioning code or drawing code causing the problem, but using the debugger will indeed help.
this is this.
|
|
|
|