How to change the window rect without redrawing it - c++

I want to change the height of an edit control window at 1st and then visualize the change through calling AnimateWindow function. But it doesn't seems to work. What should I do for this?

Use MoveWindow with bRepaint=FALSE
BOOL WINAPI MoveWindow(
_In_ HWND hWnd,
_In_ int X,
_In_ int Y,
_In_ int nWidth,
_In_ int nHeight,
_In_ BOOL bRepaint // <-- FALSE
);

Related

(Win32) How to launch a dialog box?

I'm trying to recreate the famous Windows 93 Hydra virus for Windows 95 using Microsoft Visual C++ 4.0, but due to my inexperience with Win32 I'm having trouble launching the main dialog box.
Here is what I was able to come with so far (the rest of the code can be found in this github repo):
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "resource.h"
static HINSTANCE hInstanceGlobal;
BOOL CALLBACK DialogProc(HWND H, UINT M, WPARAM W, LPARAM L);
inline int CreateHead()
{
return DialogBox(hInstanceGlobal,
MAKEINTRESOURCE(HYDRA),
0, DialogProc);
}
BOOL CALLBACK DialogProc(HWND H, UINT M, WPARAM W, LPARAM L)
{
switch (M)
{
case WM_COMMAND:
CreateHead();
CreateHead();
case WM_INITDIALOG:
return TRUE;
default:
return FALSE;
}
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
hInstanceGlobal = hInstance;
return CreateHead();
}
The program compiles, but when I run it does absolutely nothing.
What am I doing wrong? How could I achieve the desired effect?

Winrt Message Dialog not showing

I am trying to display a Message Dialog in C++ (winrt) from a Desktop Windows App targeting Win 10 x64. The following code executes but the dialog is not shown. Return code from ShowAsync is good
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
Microsoft::WRL::Wrappers::RoInitializeWrapper init(RO_INIT_SINGLETHREADED);
Microsoft::WRL::ComPtr<ABI::Windows::UI::Popups::IMessageDialogFactory> messageDialogFactory;
Microsoft::WRL::Wrappers::HStringReference messageDialogFactoryId(RuntimeClass_Windows_UI_Popups_MessageDialog);
Windows::Foundation::GetActivationFactory(messageDialogFactoryId.Get(), messageDialogFactory.GetAddressOf());
Microsoft::WRL::ComPtr<ABI::Windows::UI::Popups::IMessageDialog> messageDialog;
Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IVector<ABI::Windows::UI::Popups::IUICommand*>> uiCommands;
messageDialogFactory->CreateWithTitle(Microsoft::WRL::Wrappers::HStringReference(L"XXX").Get(), Microsoft::WRL::Wrappers::HStringReference(L"YYY").Get(), messageDialog.GetAddressOf());
messageDialog->get_Commands(uiCommands.GetAddressOf());
Microsoft::WRL::ComPtr<ABI::Windows::UI::Popups::IUICommandFactory> uiCommandFactory;
Microsoft::WRL::Wrappers::HStringReference commandFactoryId(RuntimeClass_Windows_UI_Popups_UICommand);
Windows::Foundation::GetActivationFactory(commandFactoryId.Get(), uiCommandFactory.GetAddressOf());
w::ComPtr<pu::IUICommand> button;
uiCommandFactory->CreateWithHandler(Microsoft::WRL::Wrappers::HStringReference(L"ZZZ").Get(), new ButtonHandler(), button.GetAddressOf());
uiCommands->Append(button.Get());
Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncOperation<ABI::Windows::UI::Popups::IUICommand*>> showOperation;
HRESULT hr = messageDialog->ShowAsync(showOperation.GetAddressOf());
MSG msg;
while( ::GetMessage(&msg, 0, 0, 0) > 0 )
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
return 0;
}
Should have read documentation - API doesn't have the DualApiPartitionAttribute

C++ GUI Window position

I have a GUi, written in C++/CLI . I want one specific window of it to open on a specific position (right top corner) of my display.
How can I implement this?
BOOL WINAPI SetWindowPos(
__in HWND hWnd,
__in_opt HWND hWndInsertAfter,
__in int X,
__in int Y,
__in int cx,
__in int cy,
__in UINT uFlags
);
More info on msdn.
http://www.winprog.org/tutorial/ -- That will teach you how to make a GUI for Windows only in window's native GUI implement (API).
To implement your code you need to respond to a user's action, i.e clicks a button then
do i = 1+1;

How to set the window's default position?

I'm using Dev C++. After I created a windows application, it generated some code which creates a window. I understand the code broadly. I've found the code to set the size, title, and background color but how do I set up the default position of the new window? I want to start it at the center of the screen.
You should have CreateWindow function, its definition is as follows:
HWND WINAPI CreateWindow(
__in_opt LPCTSTR lpClassName,
__in_opt LPCTSTR lpWindowName,
__in DWORD dwStyle,
__in int x,
__in int y,
__in int nWidth,
__in int nHeight,
__in_opt HWND hWndParent,
__in_opt HMENU hMenu,
__in_opt HINSTANCE hInstance,
__in_opt LPVOID lpParam
);
The x and y parameters specify the location of the newly-created window. These are the ones you need to set.

C++ don't display in the taskbar a window created with CreateWindow [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Windows Taskbar API
Win32: How to hide 3rd party windows in taskbar by hWnd
How can I prevent window from showing in the taskbar after I created it with CreateWindow? (Is there any parameter that allows me to do this, or something?)
set 'dwStyle' to WS_POPUP, the third argument:
HWND WINAPI CreateWindow(
__in_opt LPCTSTR lpClassName,
__in_opt LPCTSTR lpWindowName,
__in DWORD dwStyle,
__in int x,
__in int y,
__in int nWidth,
__in int nHeight,
__in_opt HWND hWndParent,
__in_opt HMENU hMenu,
__in_opt HINSTANCE hInstance,
__in_opt LPVOID lpParam);
If you're doing win32, I suggest, for your own sanity, you give Qt a try.
ITaskbarList::DeleteTab will also remove a window from the taskbar.