Does anyone know of a cross-platform way to resize a native window - by native i mean one that runs inside of Windows', Mac's or Linux's windowing toolkit?
开发者_开发知识库Any help would be appreciated!
There isn't one. There's even no cross-platform way to create and show a "native window" by using only standard C++.
There are cross-platform ways by using toolkits/frameworks that provide a platform-independent abstraction of the windowing system, including windows creation, resizing, custom drawing, buttons, etc...:
- Nokia's Qt: uses native drawing API's for its widgets, meaning everything will look "right", without dealing with platform abnormalities. Has great documentation and a very large featureset.
- wxWidgets: same as Qt, although some argue documentation is lacking and code can get messy.
- GTK+: looks ugly on Windows, written in pure c (has C++ wrappers, but is still c).
If you really want to abstract platform stuff yourself, you'll have to either split the source code and reimplement everything the aforementioned projects already have, or use A LOT of #ifdef's like this:
#ifdef _WIN32
// windows specific code
#elif defined(somelinuxdefine?)
//Linux code
#elif defined(somemacdefine?)
// Mac code
#endif
which is at the very least very difficult, messy, and unmaintainable.
For X11 - (for example Linux, but no only),
you might be interested with :
- sources of xdotool by Jordan Sissel, cause "tool lets you simulate keyboard input and mouse activity, move and resize windows, etc."
I am not sure, but it seems there is xdotool MacOSX and FreeBSD port as well.
精彩评论