|
I've been looking for a way to get free of GDI+ so I was game to try this out.
I downloaded the library, compiled the lib project using VC++ 6.0 in a debug configuration, created a new SDI project in VC++ 6.0, put the .lib, .dll, and .h file for the debug library that I compiled into the new projects directory to speed this up, and made the following changes to the project...
// stdafx.h
#include "FreeImage.h"
#pragma comment(lib, "FreeImaged")
// FreeTest.cpp
BOOL CFreeTestApp::InitInstance()
{
FreeImage_Initialise();
//...
}
int CFreeTestApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
FreeImage_DeInitialise();
//...
}
/*
This appears to compile but I haven't tried performing anyhting with it. What should I do to mirror your environment?
*/
|
|
|
|
|
0) Use VS2005 (I tried the pragma thing too). And then I did this:
1) Compiled the freeimagelib project for both release and debug
2) Moved the .lib files into a sub-folder under MyProject
3) Added the new lib folder to the "Linker | Additional Library Directories" setting for MyProject
4) Added the freeimage.lib (or freeimaged.lib) file to the "Linker | Additional Dependancies" setting for MyProject
4) Added the freeimage source folder (that contains the freeimage.h file) to the "C/C++ | Additional Include Directories" setting for MyProject
5) Added the FreeImagePlus include folder to the "C/C++ | Additional Include Directories" setting for MyProject
6) Added the necessary source files to MyProject
7) Added the necessary #includes (for FreeIMagePlus) to MyProject
The project compiles with no errors or warnings about not being able to find any files, but I get unresolved externals for the FreeImage stuff. Curiously, they all deal with the TIFF, MNG, PNG, and JPEG stuff.
I might just start from scratch on the project and see if I can't figure out where I went wrong.
As far as freeimage is concerned, it's a very nice library. When I get done with this project, I'm gonna post an article.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Could it be a mix up between the 'Runtime Library' settings (Project Properties|C/C++|Code Generation). For example, if one project is using 'Multi threaded' and the other 'Multi threaded DLL' then you'll get tons of linker errors.
|
|
|
|
|
I checked that, and they're the same. :/
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Long shot, but are both projects using wchar_t as a built-in type? I had some issues with this and the BCG UI library when first moving to VS2005.
|
|
|
|
|
Yeb, both have identical settings.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
Anyone have any idea to control the brightness of avi file at animation control?
thanks in advance.
|
|
|
|
|
Some times ago I saw an article on the codeproject about change brightness,hue,... of a file I think it used of mcis see C++ multimedia section on the codeproject
|
|
|
|
|
hi,
PlaySound(MAKEINTRESOURCE(IDR_WAVE1), AfxGetInstanceHandle(), SND_RESOURCE | SND_ASYNC);
PLs advice on the above what to change if i wanna to play a wavefile continously,
and what to change if i need to pause them..
Thanks
|
|
|
|
|
You could add the SND_LOOP flag to make it play continuously.
To stop playback, call PlaySound() with the first parm NULL.
For better control you may need to use the Waveform-Audio Interface[^] or DirectSound etc.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Does anyone know how to programatically register a PKCS#12 file?
|
|
|
|
|
|
Yes, I know that this is not standard, but the keyboard of the computer in which the program will run has no tab key...
OK, I'm using the PreTranslateMessage and doing this:
if (pMsg->wParam == VK_UP)
{
GetNextDlgTabItem(this->GetFocus(),TRUE)->SetFocus();
return FALSE;
}
if (pMsg->wParam == VK_DOWN)
{
GetNextDlgTabItem(this->GetFocus(),FALSE)->SetFocus();
return FALSE;
}
and it works except for a little detail:
if you put the focus on a button using tab it gains the blue border (typical in WinXP) and when you leave a button using tab it loses that blue border.
When I place the focus on a button using any of the cursor keys (VK_UP or VK_DOWN) the blue border appears, but when I leave that button the blue border continue being there.
Any idea on why do this happens?
As always thank you in advance...
|
|
|
|
|
Try removing the return FALSE in both options in the PreTranslateMesaage.
|
|
|
|
|
It makes exactly the same...
Thank you for your feedback...
|
|
|
|
|
Hi,
I'm trying to change the background color of a button (CButton type).
In order to acheive that,I'm using the ON_WM_CTLCOLOR() message,
but i'm unable to change the background color.
My code is as follow (directly from the MSDN...with few changes) :
HBRUSH CFailureListFeasibilityDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
CBrush brush;
if (pWnd->GetDlgCtrlID() == IDC_MYBUTTON)
{
pDC->SetTextColor(RGB(0, 250, 250));
pDC->SetBkColor(RGB(255,0,0));
brush.CreateSolidBrush(RGB(0,0,0));
hbr = brush;
}
return hbr;
}
When debugging,I'm entering the "if" statement,but the backgroung color
remains the same.
Can anyone help me?
With best regards,
Eli
|
|
|
|
|
Hi,
looks to me like an allocation issue. You are casting your local CBrush object into a brush handle - which one will become invalid at the end of the method, since the CBrush destructor will be called.
Using
<br />
hbr = CreateSolidBrush(RGB(0,0,0));
instead of
brush.CreateSolidBrush(RGB(0,0,0));<br />
hbr = brush;
should solve this problem.
However, I just looked into the MSDN Lib example to CWnd::OnCtlColor(...) and their Brush was defined in the header of the class, so the OnCtlColor caller most probably will not delete the Brush after using it. So using GDI's CreateSolidBrush(...) directly will cause a memory leak? It's probably best you do it exactly as in their example ... . I'm now , this should be such an easy thing ...
Andreas
-- modified at 6:27 Sunday 29th April, 2007
|
|
|
|
|
Hi,
First,thanks for your quick reply.
I don't think this is a memory leak problem,since the posted code works fine
for static control(when changing the "if" statement to check for IDC_STATIC,
which is a static control inside my form).
maybe CWnd::OnCtlColor(...) is not the right handler for that purpose?
I tried to handle the WM_BN_PAINT message but the method for that message
never being called....
thanks anyway...
Eli.
|
|
|
|
|
Yesterday I asked something similar in this same forum... PJ Arends answered me that the button controls don't react to those messages if you are not using them in OwnerDraw... (I was trying to do a text color change in a checkbox, but it seems that a checkbox is a button...
Well, at the end he recommended me to use CButtonST 3.9 class, you can find it in the CP button controls section.
PS:
I've used that control some times and it worked perfectly.
Hope this helps.
|
|
|
|
|
Hi Joan,
Thanks for your reply...
I've used CButtonST for several projects,and it is very good control.
The problem is that I can't use "open source" controls in my project(safety
issues... ).
I tried the OwnerDraw option, but my application always crashes...
Is there any tutorial about owner draw controls??
With best regards,
Eli
|
|
|
|
|
I have never used ownerdrawn controls, but I'm sure that you can find some information in the msdn or here in the CP... sorry for that...
Best regards... and luck!
|
|
|
|
|
The button background color is not the color used on the face of the button, which is what it sounds like you want to change. If you're using a theme with non-rectangular buttons, you can just barely see 1 or 2 pixels of background color around the outside of the button. If you want to change the face color, you'll need to owner-draw the button.
|
|
|
|
|
I wrote a test mfc project based on dialog, just one main dialog, three check boxes on it.
in .h file I define a bool var.
BOOL m_fCheck[3];
and a function:
afx_msg void OnCheck();
in .cpp file :
(1) in constructor:
for ( int i = 0; i < 3; i++ )
m_fCheck[i] = FALSE;
(2) in DoDataExchange
void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
for ( int i=0; i<3; i++ )
DDX_Check(pDX, IDC_CHECK1 + i, m_fCheck[i]);
}
(3) On Message Map
ON_CONTROL_RANGE(BN_CLICKED, IDC_CHECK1, IDC_CHECK3, OnCheck)
(4) OnCheck() function
void CTestDlg::OnCheck()
{
}
???: When I run this test program in debug mode, I click any check box and has
no error. But when I run this program in release mode:
A fatal error occured:
First-chance exception in ChtVCData.exe: 0xC0000096: Privileged Instruction.
I do one test today.
I change macro
ON_CONTROL_RANGE(BN_CLICKED, IDC_CHECK1, IDC_CHECK3, OnCheck)
to :
ON_BN_CLICKED(IDC_CHECK1, OnCheck)
ON_BN_CLICKED(IDC_CHECK2, OnCheck)
ON_BN_CLICKED(IDC_CHECK3, OnCheck)
And then I run in debug an release mode, no error found again. Now I can asure that the problem is on the macro
ON_CONTROL_RANGE(BN_CLICKED, IDC_CHECK1, IDC_CHECK3, OnCheck)
it equals
the three macro
ON_BN_CLICKED(IDC_CHECK1, OnCheck)
ON_BN_CLICKED(IDC_CHECK2, OnCheck)
ON_BN_CLICKED(IDC_CHECK3, OnCheck)
YES OR NO ?
----------------------------------------
Don't let habit prevent you from trying something new.
|
|
|
|
|
See here[^]. Your message handler is wrong. The handler for a *_RANGE macro has one UINT parameter, which is the control ID.
|
|
|
|
|
Thank you very much for reply. I have already solved this problem. You said right, The handler for a *_RANGE macro has one UINT parameter, which is the control ID.
----------------------------------------
Don't let habit prevent you from trying something new.
|
|
|
|
|