|
Here's a mickey mouse example.
It assumes a child control (a button in my instance) exists and has the ID of IDC_BUTTON1 (#define IDC_BUTTON1 1000)
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wWidth, wHeight;
int bWidth, bHeight;
RECT btnRect;
HWND btnHwnd;
switch (message)
{
case WM_DESTROY:
PostQuitMessage (0);
break;
case WM_SIZE:
wWidth = LOWORD(lParam);
wHeight = HIWORD(lParam);
btnHwnd = GetDlgItem(hwnd, IDC_BUTTON1);
GetWindowRect(btnHwnd, &btnRect);
bWidth = btnRect.right - btnRect.left;
bHeight = btnRect.bottom - btnRect.top;
SetWindowPos(btnHwnd, HWND_TOP, (wWidth-bWidth)/2, (wHeight-bHeight)/2, bWidth, bHeight, SWP_SHOWWINDOW);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
|
|
|
|
|
thanks a looooooooooooooooooooooot
|
|
|
|
|
Pleasure mate.
|
|
|
|
|
Didn't you just ask this around 90 minutes ago?
Since a control is a window, there is no distinction in setting the position of one or the other.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Ok, this is pretty specific question. What i am trying to do is to implement vista glass effect in my gtk+ windows app. But, i just can't gtk+ code can be easily mixed with win32 APIs, so for example here is the code which draws a black rectangle on the specified area (the area where app border extends to client window):
PAINTSTRUCT ps;
RECT lpRect;
.....
case WM_PAINT:
{
HDC hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &lpRect);
HBRUSH Brush=CreateSolidBrush(RGB(0,0,0));
lpRect.bottom = 30;
FillRect(hdc, &lpRect, Brush);
EndPaint(hwnd, &ps);
}
This works fine, but only in case of pure win32 api based app, while in gtk+ for some reason it doesn't.
As code can be mixed i have tried it this way:
HWND hwnd = (HWND)gdk_win32_drawable_get_handle (window->window);
HDC hdc = GetDC(hwnd);
if(!hdc)MessageBox(0,"err getting hdc","err",0); // hdc is not null...
the rest of the code is the same actually. Result is negative.
Another way of getting HDC was:
hdc = gdk_win32_hdc_get (window->window, window->style->black_gc, mask);
But i simply got no idea how to use this function, because as 2nd parameter - there are tons of options and i dont know gtk that good.
So maybe you can help me or maybe you know some resource where i can get help on win32 gtk programming.
I know there are standard methods for doing this in wx(?), Qt, win32, mfc, .Net, etc, but gtk+ is the only options in this case.
Thanks in advance
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
how can i get the window position
|
|
|
|
|
GetWindowRect, please read carefully the documentation page.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thanks....
|
|
|
|
|
You are welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
GetWindowRect or GetWindowRgn
|
|
|
|
|
thanks......
|
|
|
|
|
Define window position...
If it's the window position relative to the screen top-left corner, use GetWindowRect
If it's the window position relative to its parent window's top-left corner, use GetClientRect
If it's for storing the window position so you can open it at the same place next time it's run, use GetWindowPlacement
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Hello experts,
Developers sometimes provide ways for other programmers to interact with their application using API they've created.
Those API somehow "talk" with the original application they belong to.
So if application A was written by someone, application B (which was written by someone else) can do this "talking" with A using A's APIs.
I see no problem in developing a DLL which exposes functions.
But how do I go about making my DLL able to talk with my app when used by another external application?
Thanks in advance,
Shy.
|
|
|
|
|
Shy Agam wrote: But how do I go about making my DLL able to talk with my app when used by another external application?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Add interfaces direcly to your application, and expose them as COM objects. Registering the COM server will thereafter ensure that other applications can instantiate and talk to your application.
|
|
|
|
|
HI,
Is there any restriction that Dll should be in the same folder with Client exe or system folder ?
Can i place DLL any where and can Call ?
waiting for your precious advice.
Thanks,
Rayalu
|
|
|
|
|
See "Dynamic-Link Library Search Order" at MSDN .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Your dll has to be found by your application, which means that it should either be in the system folder or in the same folder of your application. However, if you explicitely load your dll (by using LoadLibrary), you can place it anywhere you want and specify the path of the dll in the call to LoadLibrary.
|
|
|
|
|
Cedric Moonen wrote: However, if you explicitely load your dll (by using LoadLibrary), you can place it anywhere you want and specify the path of the dll in the call to LoadLibrary.
I think you may do the same thing with implicit loaded DLLs if you specify the path of the dynamic libraries in the application mainifest (anyway I never made a test...).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
It also works implicit if you specify the path.
I used it to reference to the debug or release version of some dll I wrote, depending on some project setting.
Greetings
Covean
|
|
|
|
|
|
Thanks Cédric Moonen
I did same.
|
|
|
|
|
Hi all,
I have loaded a image to a bitmap object using LoadImage function. After i used the bitmap object to a button,whether can i use the same object to add image to other buttons. Will the object have the image handle? Can i use more than once that bitmap object. I tried to add that bitmap object to other buttons, its not woring.
Thanks,
|
|
|
|
|
I guess the pronlem is in your code, but I can't see it...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
What I'm doing wrong , because LPHOSTENT lpHostEnt is null :
SOCKET m_hSocket;
LPHOSTENT lpHostEnt;
CString sServer = "smtp.gmail.com";
lpHostEnt = gethostbyname(sServer);
if(lpHostEnt == NULL)AfxMessageBox("lpHostEnt is NULL");
|
|
|
|