|
i was wondering if it would be possible to load a bitmap image into a dialog-based application, to be displayed like a logo for a window and if so, possibly how i would go about doing so.
|
|
|
|
|
go to the top (of most) CodeProject pages, key 'bitmap' into the search field, Set the selector to 'Articles', press the Enter Key
you should see quite a few articles on bitmaps etc - find the one that most suits your needs and experiment with it
when you have an issue, post back a specific question with some code, rather than a 'help me' or 'please help' ..
|
|
|
|
|
Here's one way (I assume you want to load from a file):
1. Add a picture control to the dialog, be sure to set its type to "bitmap". Change to ID to something meaningful.
2. Using the ClassWizard add a member variable of type CStatic for the control, call it m_Picture .
3. Add the following to your class declaration:
HBITMAP m_hBM;
4. Add the following code to the dialog's OnInitDialog handler:
HBITMAP m_hBM = reinterpret_cast<HBITMAP>(
LoadImage(
NULL,
_T("C:\\130x130.bmp"),
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE
)
);
m_Picture.SetBitmap(m_hBM);
5. Add the following in a WM_DESTROY handler:
DeleteObject(m_hBM);
Steve
|
|
|
|
|
:-DHi,
In my project, I need code such as:
one head file:
#include "B.h"
class CA {
void fun(CB *pB);
}
Another head file:
#include "A.h"
class CB {
void fun2(CA *pA);
}
but the including each other will cause compiler error, How to solve that?
thanks.
|
|
|
|
|
1) First of all youll notice that most C++ header files have something like the following in them
This at the top of the file.
#if !defined(AFX_DEFINE_H__CE391361_8C35_11D5_AFA0_00D009BE05B6__INCLUDED_)
#define AFX_DEFINE_H__CE391361_8C35_11D5_AFA0_00D009BE05B6__INCLUDED_
and this at the bottom
#endif // !defined(AFX_DEFINE_H__CE391361_8C35_11D5_AFA0_00D009BE05B6__INCLUDED_)
This prevents the compiler from processing the declarations twice.
2) When you need class A to know about class B and class B to know about class A you can do this:
In my project, I need code such as:
one head file:
class CB;
class CA {
void fun(CB *pB);
}
Another head file:
class CA;
class CB {
void fun2(CA *pA);
}
to avoid the necesity for including the headers with the full class definitions.
|
|
|
|
|
Hi,
In my project, I need code such as:
one head file:
#include "B.h"
class CA {
void fun(CB *pB);
}
Another head file:
#include "A.h"
class CB {
void fun2(CA *pA);
}
but the including each other will cause compiler error, How to solve that?
thanks.
|
|
|
|
|
You don't need to include the headers, just define the class'.
i.e.
// File: CA.h
class CB;
class CA {
void fun(CB *pB);
}
// File: CB.h
class CA;
class CB {
void fun2(CA *pA);
}
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Thanks a lot.it really helped
|
|
|
|
|
In addition to doing the above suggestion, add #pragma once to the top of your headers.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I am trying to compile a project written in Visual C++ 6 in Visual Studio 2005.
And I have an error, saying
error C2664: 'localtime' : cannot convert parameter 1 from 'long *' to 'const time_t *'
Below is the snippet of the file
long totalSeconds = (long)(dSeconds +.5);
struct tm *myTime = localtime(&totalSeconds);//Convert to local tim
Anybody can help me?
Yonggoo
|
|
|
|
|
Short answer:
The prototype for localtime is:
struct tm *localtime(const time_t *timer);
You are passing a long* not a time_t*.
Longer answer:
time_t is a long in 32-bit OS's but a __int64 in 64-bit OS's.
As time_t has been a long for a long time (no pun intended) many developers found it more convenient to just use a long.
In VS2005 time_t is a __int64 unless _USE_32BIT_TIME_T is defined.
So, in reality you are passing a long* to a function expecting a __int64*.
Just use time_t, there is a reason it is defined as a distinct type.
e.g.
time_t totalSeconds = (time_t)(dSeconds +.5);
struct tm *myTime = localtime(&totalSeconds);
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Anyone recommend a profiler that will work with unmanaged C++/VS 2005?
Compuware seems to have bailed out on releasing the free community edition that was available for 2002/2003.
"My dog worries about the economy. Alpo is up to 99 cents a can. That's almost seven dollars in dog money" - Wacky humour found in a business magazine
|
|
|
|
|
Unfortunately, Compuware doesn't have a free version since their latest version is really nice.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I have an app written in VC++ 6.0 on XP Sp2. The app makes a socket connection to a service under normal conditions. If the service is stopped the app destroys the socket, recreates a new one and retries. The deletion, recreation, reconnect continues until successful.
However, I notice that there is an apparent memory leak. I've checked out
Process/Private Bytes & Process/Working Set using Perfmon. Both are seen to
increase during the reconnection attempts.
Any ideas please.
Dave Regan
|
|
|
|
|
Visual C++ 6.0
I've setup some context-sensitive help functionality for our app. The target window is a CView with a bunch of embedded CWnd objects. When I click on the context-help button in the toolbar, the cursor changes to the arrow/questionmark (like it should). However, if I click somewhere in the view that isn't one of the smaller CWnd's, I have the program displaying a messagebox saying there's no help. Now comes the weird part...
When I click the okay button in the messagebox, the cursor doesn't change back to the standard arrow cursor until I move the mouse over another window.
I've tried this line of code at the end of my OnContextHelp function:
AfxGetApp()->LoadStandardCursor(IDC_ARROW);
but it still doesn't change the cursor. Anyone have any ideas?
------- 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
|
|
|
|
|
Is your view possibly intercepting and discarding WM_SETCURSOR messages?
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"
|
|
|
|
|
Nope, there's no handler at all in the view for WM_SETCURSOR...
And while checking what you mentioned, I realized that I had no call to ::SetCursor(). Duh!
It's fixed now.
------- 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,
I am trying to remove a device using the fn,bOk = SetupDiRemoveDevice(hDevInfo,devinfoData[n1]);
as soon as I do this, (I think there are some bugs in its driver) it gets to the found new hardware wizard, and recreats the registries ( for I want to remove that device and delete the registries).
How do I overcome this. I know we can tell device manager to send me all the devices messages so that when I get new hardware message, I can ignore it.
Can anyone help me how to do that?
Thanks in advance.
|
|
|
|
|
Hi, I would like to learn how to change registry entries from a MFC (dialog based) application. I am trying to disable the Task Manager when my application loads and disable it before I exit.
Any help would be greatly apperciated. Thanks,
This is the entry i'm trying to change:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]---->DisableTaskMgr
|
|
|
|
|
Use RegSetValueEx(.....) to set the registry value
cheers,
Super
------------------------------------------
Too much of good is bad,mix some evil in it
|
|
|
|
|
Thanks Super, that worked!
|
|
|
|
|
I am using Visual C++ 6.0. I have an MFC Dialog based application. I have an class derived from CDialog called CIntrument that has edit controls. Each edit control has a unique IDD_EDIT identifier and have unique variables defined as Value CString. In a different CDialog box I instantiate an object of type 'CInstrument Inst'. I then use fscanf() to read text from a file into the member variables Inst.m_var_a, Inst.m_var_b, Inst.m_var_c and others. As each item of text is read ALL the member variables change to the value that was just read. I have verified this while stepping through the code one line at a time. I am very confused as to why variables with completely different names would be modified in this fashion.
Thanks
Buck
|
|
|
|
|
Open the resource.h and the .rc file using the text editor and confirm that each edit control really does have a unique ID and that that ID is really a unique value.
Next, check DoDataExchange and verify that the controls and the member variables are being assigned correctly.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Yes, everything seems to be the way you would expect it.
Buck
|
|
|
|
|
Darn, then I'm at a loss without looking at the source.
Could it have to do with how fscanf() is being used?
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|