|
If your image file is only a bitmap then use this Bitmap constructor:
Bitmap::Bitmap(gdiBitmapInfo, gdiBitmapData)
Creates a Bitmap object based on a BITMAPINFO structure and an array of pixel data.
Bitmap(
const BITMAPINFO* gdiBitmapInfo,
VOID* gdiBitmapData
);
If you would like to create the stream from the image file that you have loaded into memory, you will first need to make sure that that memory was allocated with this function GlobalAlloc then you can call this function CreateStreamOnHGlobal in order to create a stream object that is initialized with your image data.
Just make sure to call the Release method on the IStream interface that it returns to you.
|
|
|
|
|
Much appreciated!
What happens if the operation is in reverse and I am svaing a bitmap to the stream. Do i just have to make sure i have a globalalloc big enough. Any ideas?
Thanks Again
Rich![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
I'm looking for a working sample that demonstrates how to show a tracking tooltip. What I'm trying to do is manually show a balloon tooltip pointing at a static control in a dialog. AFAICT my code matches what's in MSDN, but I've had no luck.
Here's what I have so far, it's your standard MFC dialog:
BOOL CTipTestDlg::OnInitDialog()
{
m_tip.Create ( this, TTS_BALLOON );
TOOLINFO ti = { sizeof(TOOLINFO), TTF_TRACK|TTF_ABSOLUTE, GetSafeHwnd(),
IDC_LABEL, {0}, NULL, LPSTR_TEXTCALLBACK };
m_label.GetWindowRect ( &ti.rect );
ScreenToClient ( &ti.rect );
m_tip.SendMessage ( TTM_ADDTOOL, 0, (LPARAM) &ti );
m_tip.SendMessage ( TTM_SETTITLE, 1, (LPARAM) "Title here" );
m_tip.Activate(TRUE);
} I want the tip to appear when I click OK:
void CTipTestDlg::OnOK()
{
CRect rc;
TOOLINFO ti = { sizeof(TOOLINFO), TTF_TRACK|TTF_ABSOLUTE, GetSafeHwnd(), IDC_LABEL,
{0}, NULL, LPSTR_TEXTCALLBACK };
m_label.GetWindowRect ( &ti.rect );
ScreenToClient ( &ti.rect );
m_label.GetWindowRect(rc);
m_tip.SendMessage ( TTM_TRACKACTIVATE, TRUE, (LPARAM) &ti );
m_tip.SendMessage ( TTM_TRACKPOSITION, 0, MAKELONG(rc.left, rc.top) );
} No matter what I try, the tooltip never appears. When I flip the flags to make it a regular tooltip, it works, so I know my tip-related code is OK. It's just the track activate/track position part that I'm stuck on.
--Mike--
Rollin' in my 5.0
With the rag-top down so my hair can blow.
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Hi Michael, I know close to zero about tracking tooltips, but found this article about them with seemingly good stuff on the subject. First thing that caught my eye is the guy sends the two messages TTM_TRACKPOSITION and TTM_TRACKACTIVATE in reversed order than you. Could this make a difference?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
I have a few classes I want to put in a DLL. These class and resources uses other side classes. Now, if I include these side classes with the main classes, and then in my prohgram that I want to link the DLL to also have these classes (because they are like CButtonXX and other types) what will happen?
How should I be strcuturing something like this? All my classes and dialogs rely on the same inherited Button, label ect classes. So the big if is if I have TWO DLL that has two diff ... that both rely on these side classes. Now what will happen if I want to link them to a project?
Thanks in advance.
|
|
|
|
|
My guess is you won't have any problem with the scenario you describe, apart from some bloat due to the duplication of CButtonXX code. For added safety, make sure none of the classes exported has any method inline (i.e. defined inside the class declaration), so you will rest asure each part uses its own CButtonXX instantiation.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Without changing anything I can no longer compile. It looks like I'm missing some library or something. Does anyone have any ideas? Here's my error messages.
nafxcwd.lib(strcore.obj) : warning LNK4006: "void __stdcall
SerializeElements(class CArchive &,class ATL::CStringT<char,class
StrTraitMFC<char,class ATL::ChTraitsCRT<char> > > *,int)"
(?SerializeElements@@YGXAAVCArchive@@PAV?$CStringT@DV?$StrTraitMFC@DV?$ChTra
itsCRT@D@ATL@@@@@ATL@@H@Z) already defined in CCrystalTextHelper.obj; second
definition ignored
CCrystalTextHelper.obj : error LNK2019: unresolved external symbol
"protected: class CMap<int,int,unsigned long,unsigned long>::CAssoc *
__thiscall CMap<int,int,unsigned long,unsigned
long>::GetAssocAt(int,unsigned int &,unsigned int &)const "
(?GetAssocAt@?$CMap@HHKK@@IBEPAVCAssoc@1@HAAI0@Z) referenced in function
"public: int __thiscall CMap<int,int,unsigned long,unsigned
long>::Lookup(int,unsigned long &)const " (?Lookup@?$CMap@HHKK@@QBEHHAAK@Z)
CrystalEditorColorsDlg.obj : error LNK2001: unresolved external symbol
"protected: class CMap<int,int,unsigned long,unsigned long>::CAssoc *
__thiscall CMap<int,int,unsigned long,unsigned
long>::GetAssocAt(int,unsigned int &,unsigned int &)const "
(?GetAssocAt@?$CMap@HHKK@@IBEPAVCAssoc@1@HAAI0@Z)
SyntaxOptions.obj : error LNK2001: unresolved external symbol "protected:
class CMap<int,int,unsigned long,unsigned long>::CAssoc * __thiscall
CMap<int,int,unsigned long,unsigned long>::GetAssocAt(int,unsigned int
&,unsigned int &)const " (?GetAssocAt@?$CMap@HHKK@@IBEPAVCAssoc@1@HAAI0@Z)
CrystalEditorColorsPropPage.obj : error LNK2001: unresolved external symbol
"protected: class CMap<int,int,unsigned long,unsigned long>::CAssoc *
__thiscall CMap<int,int,unsigned long,unsigned
long>::GetAssocAt(int,unsigned int &,unsigned int &)const "
(?GetAssocAt@?$CMap@HHKK@@IBEPAVCAssoc@1@HAAI0@Z)
CCrystalTextHelper.obj : error LNK2019: unresolved external symbol
"protected: class CMap<class ATL::CStringT<char,class StrTraitMFC<char,class
ATL::ChTraitsCRT<char> > >,char const *,class CKeywordList *,class
CKeywordList *>::CAssoc * __thiscall CMap<class ATL::CStringT<char,class
StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >,char const *,class
CKeywordList *,class CKeywordList *>::GetAssocAt(char const *,unsigned int
&,unsigned int &)const "
(?GetAssocAt@?$CMap@V?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@AT
L@@PBDPAVCKeywordList@@PAV3@@@IBEPAVCAssoc@1@PBDAAI1@Z) referenced in
function "public: class CKeywordList * & __thiscall CMap<class
ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> >
>,char const *,class CKeywordList *,class CKeywordList *>::operator[](char
const *)"
(??A?$CMap@V?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@PBDPAV
CKeywordList@@PAV3@@@QAEAAPAVCKeywordList@@PBD@Z)
Thanks.
|
|
|
|
|
Hmmm, have you tried a "Rebuild All"?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
yes - i've tried it. i've even reinstalled vc7 but i think i'm not linking to some library that should be. i don't know what's happened. it's like my lib is gone - the problem is, i'm not sure which lib it is.
|
|
|
|
|
Hello, the codegurus around the world.;)
Error message says that you can compile the code, but not link the library
needed.
So, try to check your setting of how to find the library path and so on.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
dear all,
how can i restrict multiple instance of
an exe?
please.......
anju
|
|
|
|
|
Run it on a very small computer...
... or, check J.M.Newcomers (IIRC) exellent article (here on CP), or, search this forum for CreateMutex and you'll get some tips.
|
|
|
|
|
ROFLMAO
<centre>
"Never tell people how to do things. Tell them what to do, and they will surprise you with their ingenuity." - General George S. Patton Jr.
|
|
|
|
|
No - seriously - this Newcomer guy is good!
|
|
|
|
|
Create a named mutex object when your app starts up. In your second app, if another mutex exists with that name, then exit the program. This is how VB implements their version of this.
|
|
|
|
|
kilowatt wrote:
This is how VB implements their version of this.
I didnt know that. How is it done from VB?
Nish
Oh, I don't know why she's
leaving, or where she's gonna go
I guess she's got her reasons but I just don't wanna know
'Cos for 24 years I've been living next door to Alice
24 years just waitin' for a chance
To tell her how I feel and maybe get a second glance
Now I gotta get used to not living next door to Alice
|
|
|
|
|
kilowatt wrote:
This is how VB implements their version of this.
I didnt know that. How is it done from VB?
Forget about it! Even if this is the "offical" way to do it, it has some bad limitations, especially in NTs multiuser/multidesktop environment. I strongly recommend to read the excellent article from Joseph which shows everything about this topic. Some ready to use C-Code can that takes account of this problems can be found here.
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
I think Nish was simply asking how you get access to the previous instance feature in VB. I don't think that just because VB implements it this way, that says this is the "official" way to do it.
|
|
|
|
|
You reference the app object and test the hPrevInstance variable. It will return true if there is an previous instance of the app, false if there is not.
If (App.PrevInstance) Then
MsgBox "Previous Instance Found"
Else
MsgBox "No Previous Instance"
End If
Basically this feature is implemented internally with the named mutex as I mentioned earlier in the thread.
|
|
|
|
|
This is what I use.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
create a static instance for a type
ex: static CMyClass *pInstance;
// you need to initialize it...
CMyClass *CMyClass::pinstance = NULL;
add the following functions
// constructing the object
CMyClass *CMyClass::GetInstance()
{
if(pInstance== NULL)
pInstance = new CMyClass;
return pInstance;
}
// destructing the object
void CSystemManager::DeleteInstance()
{
if( pInstance)
delete pInstance;
pInstance = NULL;
}
apart from constructor and destructor...
Now... you can happily access the singleton thro GetInstance() function.
call DeleteInstance() when you are done with that.
-anu
|
|
|
|
|
ihave a probelm, i got a property sheet and some property pages, when i try to add controls like buttons or whatever, the program crashes, could it be that i'm using the property page in a dockable toolbar ? there are no memory leaks anyway, i don't know how to solve it.![Cry | :((](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_cry.gif)
|
|
|
|
|
|
maybe the idea is stupid
class CBookFormatsDlg : public CDialog
{
// Construction
public:
CBookFormatsDlg(CWordFormat *pWordFormat = NULL,UINT nDlgIDD = IDD_BOOK_FORMATS,CWnd* pParent = NULL); // standard constructor
virtual ~CBookFormatsDlg();
// Dialog Data
//{{AFX_DATA(CBookFormatsDlg)
enum { IDD = IDD_BOOK_FORMATS };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
CPropertySheet* m_dlgPropSheet;
CTitleSet* m_pTitleSet;
CPageSet* m_pPageSet;
COtherSet* m_pOtherSet;
// ....
};
--------------------------------------------------------------------------------------------------
CBookFormatsDlg::CBookFormatsDlg(CWordFormat *pWordFormat,UINT nDlgIDD,CWnd* pParent /*=NULL*/)
: CDialog(nDlgIDD, pParent)
{
//{{AFX_DATA_INIT(CBookFormatsDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_dlgPropSheet = new CPropertySheet();
m_pTitleSet = new CTitleSet();
m_pPageSet = new CPageSet();
m_pOtherSet = new COtherSet();
m_pWFormat = pWordFormat;
m_pWordFormats = &(((CTdbookApp *)AfxGetApp())->m_sysWordFormats);
m_nPreSelIndex = -1;
m_nSelFormatID = -1;
}
CBookFormatsDlg::~CBookFormatsDlg()
{
if( m_pTitleSet != NULL)
delete m_pTitleSet;
if( m_pPageSet != NULL)
delete m_pPageSet;
if( m_pOtherSet != NULL)
delete m_pOtherSet;
if( m_dlgPropSheet != NULL)
delete m_dlgPropSheet;
}
BOOL CBookFormatsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// ...
m_dlgPropSheet->AddPage(m_pTitleSet);
m_dlgPropSheet->AddPage(m_pPageSet);
m_dlgPropSheet->AddPage(m_pOtherSet);
m_dlgPropSheet->Create(this, WS_CHILD | WS_VISIBLE, 0);
m_dlgPropSheet->ModifyStyle(0, WS_TABSTOP);
m_dlgPropSheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT);
CRect rcSheet;
CWnd *pWnd = GetDlgItem(IDC_SHEETS);
if( pWnd != NULL )
{
pWnd->GetWindowRect(&rcSheet);
ScreenToClient(rcSheet);
}
else
GetWindowRect(&rcSheet);
m_dlgPropSheet->SetWindowPos(NULL, rcSheet.left-4, rcSheet.top-4, rcSheet.Width(), rcSheet.Height(),
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
m_dlgPropSheet->SetActivePage(0);
// ....
return TRUE;
}
|
|
|
|
|