|
WS_THICKFRAME gives the window a thick frame as expected, however it doesn't affect the title in any way.
I've tried removing my DirectX code, yet the window remains without a title.
I'm tearing my hair out over this!!
|
|
|
|
|
With a few minor changes (to work in my environment), your code snippet worked fine for me.
LRESULT CALLBACK WndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
WNDCLASSEX wndClass;
wndClass.cbClsExtra = NULL;
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.cbWndExtra = NULL;
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.hCursor = ::LoadCursor(NULL, IDC_ARROW);
wndClass.hIcon = ::LoadIcon(NULL, IDI_APPLICATION);
wndClass.hIconSm = ::LoadIcon(NULL, IDI_APPLICATION);
wndClass.hInstance = AfxGetInstanceHandle();
wndClass.lpfnWndProc = WndProc;
wndClass.lpszClassName = "MyWndClass";
wndClass.lpszMenuName = NULL;
wndClass.style = CS_CLASSDC;
RegisterClassEx(&wndClass);
HWND mHWnd = CreateWindowEx(0, "MyWndClass", "MyTitle",
WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
NULL, NULL, AfxGetInstanceHandle(), this);
"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
|
|
|
|
|
I'm thinking then that it has something to do with my msgRouter() or wndProc() - I've tried an empty wndProc that simply returns defWindowProc() with no luck.
LRESULT CALLBACK Window::msgRouter(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if(msg == WM_NCCREATE)
{
Window *window = reinterpret_cast<Window*>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<long>(window));
return TRUE;
}
else
{
Window *window = (Window*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
if(window)
{
return window->wndProc(msg, wParam, lParam);
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
LRESULT CALLBACK Window::wndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
return 0;
default:
break;
}
break;
default:
break;
}
return DefWindowProc(mHWnd, msg, wParam, lParam);
}
|
|
|
|
|
I'm facepalming over this.
I really am.
I was just digging through MSDN docs on designing a window procedure, just for the hell of it.
It said the following: "The WM_NCCREATE message is sent just after your window is created, but if an application responds to this message by returning FALSE, CreateWindowEx function fails. The WM_CREATE message is sent after your window is already created."
I thought to myself, "hmm - maybe setWindowLong() is failing or doing something funny if the window only half-exists at this point. I'll try WM_CREATE instead"
lo and behold the title shows up!
msgRouter, fixed version:
LRESULT CALLBACK Window::msgRouter(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if(msg == WM_CREATE)
{
Window *window = reinterpret_cast<Window*>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<long>(window));
return TRUE;
}
else
{
Window *window = (Window*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
if(window)
{
return window->wndProc(msg, wParam, lParam);
}
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
|
|
|
|
|
(clap) (clap) (clap)
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I have the application which will send udp broadcast message.
And it is working fine xp. but in vista it is getting failed in release version.
Debug version working fine in vista.
what could be the problem ?
|
|
|
|
|
It can be an rights or firewall issue. Switch the Firewall off (for testing!!!) or are you debugging as Administrator?
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Firewall is switched off. and UAC is disabled. Running in administrator rights.
|
|
|
|
|
That sound really bad.
I dont have any clue so dig in the MSDN whether UDP-broadcast are not allowed
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi,
I am getting following error when running my application on visual studio 8."Error 1 error PRJ0019: A tool returned an error code from "Registering ActiveX Control...". Look like properties setting issue however not able to trace it exactly. Could you please help me.
Thanks
Pankaj
|
|
|
|
|
It should be somewhere inside tools->options Project->Properties->Custom Build Setup..."Post Build". Most likely the output file is configured to be registered using "regsvr32"
Suhredayan
modified on Thursday, December 17, 2009 1:09 AM
|
|
|
|
|
It is registering in Project->Properties-Custom Build Setup as
Command Line :-regsvr32 /s /c $(TargetPath)
echo regsvr32 exec. time > $(OutDir)\regsvr32.trg
Outputs :-$(OutDir)\regsvr32.trg
Do i need to modify or remove it? I aapreciate your time
Thanks
Pankaj
|
|
|
|
|
Does this[^] help?
-Suhredayan
|
|
|
|
|
|
yes remove Outputs entry and it work
Thanks
Pankaj
|
|
|
|
|
you need to register the control with admin rights !!! You better use for that a console window
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Anyone please help me to read write 3 differnt structure to a file...and read them searching the file....like
struct A
{
int id;
int data;
};
struct B
{
int id;
float data;
};
struct C
{
int id;
double data;
int data2
};
-----------------------------
I am a beginner
|
|
|
|
|
|
thanks...
I quickly read the article, its somewhat interesting...I need to write the different type of class..not only the one....in that case please help me ...
One more important thing is that I am not using MFC...its a pure C++ console based application
-----------------------------
I am a beginner
modified on Thursday, December 17, 2009 12:42 AM
|
|
|
|
|
|
You mean plain text? You could keep every such struct as a "section" and use an .inf file to store the values. For example, for a string value, you could use WritePrivateProfileString[^] (and there's an 'int' variant, and so on). For reading, use GetPrivateProfileString[^]. This would be plain text and readable. If you need encryption, you must take care of it.
You might as well serialize[^] your data.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
thanks a lot...but i need a file system only ...not INI file...preferably a binary file
-----------------------------
I am a beginner
|
|
|
|
|
I already gave you some code, but OK, it was incomplete.
Let's try a plain, not object oriented, C -Like approach:
#include <stdio.h>
enum SerialType
{
eTYPE_UNRECOGNIZED,
eTYPE_A,
eTYPE_B,
eTYPE_C,
eTYPES
};
struct A
{
int id;
int data;
};
struct B
{
int id;
float data;
};
struct C
{
int id;
double data;
int data2;
};
size_t getSize(SerialType st)
{
switch( st)
{
case eTYPE_A:
return sizeof(A);
case eTYPE_B:
return sizeof(B);
case eTYPE_C:
return sizeof(C);
default:
return 0;
}
}
bool store( SerialType st, void * pData, FILE * fp)
{
int type = st;
size_t size = getSize(st);
if (!fp || !pData || !size) return false;
fwrite(&type, sizeof(type), 1, fp);
fwrite(pData, size,1,fp);
return true;
}
SerialType readType( FILE * fp)
{
SerialType type;
if (!fp ) return eTYPE_UNRECOGNIZED;
if ( fread(&type, sizeof(type), 1, fp) == 0 ) return eTYPE_UNRECOGNIZED;
return type;
}
bool readData( SerialType st, void * pData, FILE * fp)
{
size_t size = getSize(st);
if ( !fp || !pData || !size ) return false;
fread(pData, size, 1, fp);
return true;
}
void main()
{
SerialType type;
A a[2];
B b;
C c1,c2;
A * pa=NULL;
B * pb=NULL;
C * pc=NULL;
a[0].data = 5;
a[0].id = 12;
a[1].data = 6;
a[1].id = 13;
b.data=25.75f;
b.id=100;
c1.data = 27;
c1.data2=35;
c1.id = 7;
c2.data=1000.372;
c2.data2=1000;
c2.id=1;
FILE * fp = fopen("data.raw", "wb");
store(eTYPE_C, &c2, fp);
store(eTYPE_A, &a[1], fp);
store(eTYPE_B, &b, fp);
store(eTYPE_A, &a[0], fp);
fclose(fp);
fp = fopen("data.raw", "rb");
while ((type=readType(fp)) != eTYPE_UNRECOGNIZED)
{
switch (type)
{
case eTYPE_A:
pa = new A();
readData(type, pa, fp);
printf("type A, id=%d, data=%d.\n", pa->id, pa->data);
delete pa;
break;
case eTYPE_B:
pb = new B();
readData(type, pb, fp);
printf("type B, id=%d, data=%g.\n", pb->id, pb->data);
delete pb;
break;
case eTYPE_C:
pc = new C();
readData(type, pc, fp);
printf("type C, id=%d, data=%g, data2=%d.\n", pc->id, pc->data, pc->data2);
delete pb;
break;
}
}
fclose(fp);
}
Please note, an object oriented approach would be better: serialization fits well into OOP paradigm (however, any attempt about left to the reader...).
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]
|
|
|
|
|
Hi
I am trying to use the theme images for the start menu in Vista. It has areas that are fully transparent (around the corners), areas that are fully opaque (for the menu items) and translucent areas for the black frame.
I tried DrawThemeBackground but the translucent areas show opaque. So basically I get either alpha 0 or alpha 255. Nothing inbetween. I looked up the image in the msstyles file (it is image #717) and it has the correct opacity values. Here's my code:
BITMAPINFO dib = {sizeof(dib)};
dib.bmiHeader.biWidth = rc.right;
dib.bmiHeader.biHeight = rc.bottom;
dib.bmiHeader.biPlanes = 1;
dib.bmiHeader.biBitCount = 32;
dib.bmiHeader.biCompression = BI_RGB;
unsigned int *bits;
HBITMAP bmp=CreateDIBSection(hdc,&dib,DIB_RGB_COLORS,(void**)&bits,NULL,0);
SelectObject(hdc,bmp);
SetDCBrushColor(hdc,0x0);
FillRect(hdc2,&rc,(HBRUSH)GetStockObject(DC_BRUSH));
DrawThemeBackground(theme,hdc,SPP_PLACESLIST,0,&rc,&rc);
I then check the alpha values in the bits array and besides couple of pixels with alpha=0 all the rest are 255.
Any ideas how to get the true opacity?
|
|
|
|
|
Did you tried AlphaBlend [^]
Величие не Бога может быть недооценена.
|
|
|
|
|