Hi guys I'm new here,
I am trying to make a DLL so that I call a certain function in that DLL, it will create a child window for the current program from where I call that function(this is going to be called on a different language).
I got it to work, but the problem is after the child window pop up, after a server seconds it disappears, but when I hover the area where it used to be parts of the child window appear, meaning it is there but has become invisible somehow.
Let me know if there's a way to fix this.
Much appreciated.
I will also add my code(btw I got the code from this forum)
Code:
#include "stdafx.h"
#include <mmsystem.h>
HWND window = NULL;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK HelloWndProc(HWND, UINT, WPARAM, LPARAM);
_DLLAPI int __stdcall CreateWin(HWND hwnd)
{
HINSTANCE hInstance = (HINSTANCE)hwnd;
static TCHAR szAppName2[] = TEXT("SineApplication");
HWND hwnd2;
MSG msg;
WNDCLASS mywndclass;
mywndclass.style = CS_HREDRAW | CS_VREDRAW;
mywndclass.lpfnWndProc = WndProc;
mywndclass.cbClsExtra = 0;
mywndclass.cbWndExtra = sizeof(long);
mywndclass.hInstance = hInstance;
mywndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
mywndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
mywndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
mywndclass.lpszMenuName = NULL;
mywndclass.lpszClassName = szAppName2;
if (!RegisterClass(&mywndclass))
{
MessageBox(NULL, TEXT("Not Working"),
szAppName2, MB_ICONERROR);
return 0;
}
hwnd2 = CreateWindow(szAppName2,
TEXT("Hello World"),
WS_CHILD | WS_VISIBLE | WS_CAPTION
| WS_SYSMENU | WS_THICKFRAME
| WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS,
CW_USEDEFAULT,
CW_USEDEFAULT,
300,
300,
hwnd,
NULL,
hInstance,
NULL);
SetParent(hwnd2, hwnd);
ShowWindow(hwnd2, SW_SHOW);
UpdateWindow(hwnd2);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch (message) {
case WM_CREATE:
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rect);
DrawText(hdc, TEXT("Welcome to child window"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}