|
hai,
I want to attach a bitmap to my button control.I'm using win32 vc++ and I am just the beginner to vc++. I used loadbitmap() and sendmessage() to button control.It worked.But I was requested to do with subclassing. I pretty much have no idea.I tried MSDN. It's there for MFC (subclassdlgitem())but I want to do in win32.Can anyone help me?
|
|
|
|
|
Subclassing in Win32 requires that you write your own window procedure (see WindowProc in MSDN) and specify it as the lpfnWndProc parameter in the WNDCLASS structure you use to register your window class. You use the class name you used in the WNDCLASS structure in your call to CreateWindow when you want to create your button.
see MSDN for: WindowProc, WNDCLASS, RegisterClass, CreateWindow.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
You can try to do something like this....
<br />
WNDPROC wpOrigButtonProc; <br />
<br />
LRESULT APIENTRY DlgProc(<br />
HWND hwndDlg, <br />
UINT uMsg, <br />
WPARAM wParam, <br />
LPARAM lParam) <br />
{ <br />
HWND hwndButton; <br />
<br />
switch(uMsg) <br />
{ <br />
case WM_INITDIALOG: <br />
hwndButton = GetDlgItem(hwndDlg, ID_BUTTON); <br />
<br />
wpOrigButtonProc = (WNDPROC) SetWindowLong(hwndButton, <br />
GWL_WNDPROC, (LONG) ButtonSubclassProc); <br />
return TRUE; <br />
<br />
case WM_DESTROY: <br />
SetWindowLong(hwndButton , GWL_WNDPROC, <br />
(LONG) wpOrigButtonProc); <br />
break; <br />
} <br />
return FALSE; <br />
UNREFERENCED_PARAMETER(lParam); <br />
} <br />
<br />
LRESULT APIENTRY ButtonSubclassProc(<br />
HWND hwnd, <br />
UINT uMsg, <br />
WPARAM wParam, <br />
LPARAM lParam) <br />
{ <br />
switch(uMsg)<br />
{<br />
case ....<br />
<br />
}<br />
<br />
return CallWindowProc(wpOrigButtonProc, hwnd, uMsg, <br />
wParam, lParam); <br />
} <br />
I hope this helps you out.
|
|
|
|
|
hai,
Thanks a lot.I understood your code.But inside this subclass procedure what I should do to attach my bitmap to the button?
thanks.
|
|
|
|
|
Well catch WM_PAINT or something and use StretchBlt or BitBlt to draw the image in the button window. You will have to check if WM_PAINT is the most appropriate message to use here...
|
|
|
|
|
Hi Guys,
Iam working on an Mfc Project & have to use the VsflexGrid Control(Videosoft FlexGrid -version 8,lightunicode).Have some questions regarding that & would be nice if someone could clarify it stating the exact member function to use.
[1] Have 1 Fixed Column & 1 Fixed Row,in Which I intend to enter some user Labels.
How can I enter text("Userlabeltext") in a particular cell in a fixed column or row.
Can I use the same function for entering "text" in other cells also(In non Fixed Rows & Columns).
[2]Have a row in which I have 3 cells.
In the 1st cell,I want to have a Editable ComboBox.(ie: user should see the populated combobox as well as he can type something,which would be saved & populated later in the combo).
[a] How Can I put a combobox in a particular cell inside a VsFlexGrid control.
[b]How can I populate the combobox.
[2A]In the 2nd cell,I want to have a Non-Editable ComboBox,where only populated things in the combox box should be displayed.The user is not allowed to type anything in the combobox.(Is it possible to insert a ListBox here instead of a combo).
How can I do this(either list or combo)
[2B] In the 3rd cell,want to have a checkbox.How Can I put a checkbox in this cell.
[2C] In the 4th cell,I want to have a editable textbox.
[a] How can I populate the textbox with the defaultvalue.
[3] How can I change the Font of a Text,in the fixed row & column
So Thanks..........
|
|
|
|
|
Hi All,
I need to develope a filter driver in 2000.
At the driver level, i need to know which files are opened, read, written and closed.
While i try to do this, Iam not able to get the full file name.
I mean, iam getting the file name without the Drive Name.
Eg.
If the file opened is C:\New\xx.txt, Iam getting the file name as \New\xx.txt.
Iam getting this info from File_Object's filename.
Also, for a mapped drive iam getting the drive name properly!
How to get the drive name correctly for other drives?
With Regards,
A.Ilamparithi.
|
|
|
|
|
Hi,
How do I secure access database file. I have an application written in vc++. When the database is opened, I want to prevent the file being viewed by MS-access or make a copy of the file. Is it possible??
VYJU
|
|
|
|
|
Open the database using Access. On the Tools menu, select Security, and then Set Database Password. Now no matter how it is opened, a password must be supplied. The .MDB file can be copied from outside of Access, however. To prevent this, an OS-level security setting would be required.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
HI,
Wt meassge is generated on window maximmize.
and how it can be handled ....n where ...
any idea .. assume that i want to show a MessageBox
when window is Maximize after minnimizing.
any code or help;
thanx
|
|
|
|
|
catch WM_SIZE in simple SDK or OnSize in MFC and they receive
SIZE_MAXIMIZED
The window has been maximized.
SIZE_MINIMIZED
The window has been minimized.
and other messages....
check MSDN....
|
|
|
|
|
thanx it worksss
Can u answer mine question below here in fourm abut Slider Control
thanx
|
|
|
|
|
HI,
I build my own Video file player.
Now wanaa use CSliderCtrl that will move onwards as the file runs ,,, same as in Windows media player
i looked in code project but this kind of sample not
there.
any sample .. or help code
thanx
|
|
|
|
|
Can you get the timeline of the file?
Then you can synchronize your slider with this.
(adjusting the position every second or something)
you can also try every # of frames of your video. (eg. every 5 frames set next position etc...)
Just ideas hope they help.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
hi,
I have created a Bmp object using GDI+.
Bitmap bmp(400,500);
Now I want to save this Object as Gif File with Different Color Palette.I know that we can save the Gif file like this..
CLSID imageClsid;
GetEncoderClsid(L"image/gif", &imageClsid);
bmp.Save(wst, &imageClsid, NULL);
BUT I want to save the bmp as gif file with DIFFERENT COLOR PALETTE.How do I do that.....
please help me..
|
|
|
|
|
Hi all,
a couple of questions
1)When my process is terminated, say from the taskmanager, what is the callback message I need to use?
2)I assume if my process is being terminated because of a system shutdown I would use WM_ENDSESSION, is this correct?
Thanks again for all your help,
you guys are the greastest,
-bacon
|
|
|
|
|
AmericanBacon wrote:
When my process is terminated, say from the taskmanager, what is the callback message I need to use?
If your process is terminated from taskmanager you don't get any notification at all.
AmericanBacon wrote:
I assume if my process is being terminated because of a system shutdown I would use WM_ENDSESSION, is this correct?
Yes.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I can't believe it. The following line of code takes 30 seconds or more to finish. It does not happen all the time, which is even worse. For most of the time, everything just work fine. But once in a while, the program freeze for half a minute or more. The program log tells that it block at the following line. The worst thing is that I cannot reproduce the problem in my deveoping environment. It just happen on the customer's machine
HICON h = (HICON)LoadImage(0,strFile, IMAGE_ICON, nWidth, nHeight, LR_LOADFROMFILE);
Anybody can help me?
|
|
|
|
|
LoadIcon being a single API-call can hardly have anything to do with this. As much as I hate it in a support situation, this ought to be a problem with the user machine. A further investigation of indexing services, check of background processes, harddisk surface check etc. will probably be more fruitful than staring at the offending line. You might want to check so that the load is made as seldom as possible in your code, however. For example, preloading the icon in a ctor rather than in OnPaint .
|
|
|
|
|
Can we read data to struc directly? Follow coded are OK?
Can we read data to struc directly? Follow coded are OK?
typedef struct tagSTRUC
{
short iVer;
long a[10];
union {
short s[2];
long l;
} Comm;
float f1;
float f2[512];
flaot f3[48];
char name[128];
char nameext;
short ip;
short id;
double ddl;
double dde[256];
char cgap[46];
short dataOK;
}STRUC
void Fun()
{
STRUC mySTRUC, pSTRUC;
FILE *fp;
char fname[] = "fname.txt";
fp = fopen(fname, "r");
int iLength = sizeof(STRUC);
pSTRUC = &mySTRUC;
fread( pSTRUC, sizeof(char), iLength, fp );
/* if the read statement id OK?*/
}
|
|
|
|
|
The best way is not to use C style file handling, but use C++, with iostreams, and write stream handlers for your struct.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I believe he asked if he could do it that way, not a better way to do it.
Try this way...
<br />
#include "stdio.h"
<br />
struct XYZSTRUCT<br />
{<br />
int n1;<br />
double d1;<br />
char c[25];<br />
};<br />
<br />
XYZSTRUCT xyzItem;<br />
int nItemsRead = 0;<br />
<br />
FILE* f = fopen("MyFile.xyz", "rb");<br />
if (f)<br />
{<br />
itemsRead = fread(&xyzItem, sizeof(XYZSTRUCT), 1, f);<br />
fclose(f);<br />
}<br />
if (itemsRead < 1)<br />
{<br />
}<br />
Of course, Christian might be right about his claim that IOstreams are better, but sometimes, something quick and dirty like this are called for.
Keep in mind that you should stick with standard C++ types and not use MFC types when you're doing it this way.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi all,
I am fixing some defects in a huge code base, There's a function, say, func1 ()in which after even a long investigation, I am unable to find which function of the code base calls this function..
I there any way to find this out..This code has got multiple threads..can somebody suggest any free tool which can show the function call stack or any other means of finding this out..
Thanks,
Shiva P
|
|
|
|
|
one tool will do both of these things for you. It's from Microsoft and it's called Visual Studio. It will search for the function call across an entire project ( actually, Microsoft Windows is also worth checking out, it'll search all the text within a directory structure for you ), and if you put a breakpoint in your function and run in debug mode, you'll be able to see a call stack.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
if you want to do it programmatically, You can try looking at StackWalk
msdn online has This[^] to say about it
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|