|
Check bmp file is avaialble in folder.Otherwise it returns NULL.
Anu
|
|
|
|
|
Thanks its working...but what I need to change in code If I load a png/jpg image...
|
|
|
|
|
I use this code
HBITMAP mLoadImg(WCHAR *szFilename)
{
HBITMAP result=NULL;
Gdiplus::Bitmap* bitmap = new Gdiplus::Bitmap(szFilename,false);
bitmap->GetHBITMAP(NULL, &result);
delete bitmap;
return result;
}
Note: You have to startup and shutdown the GDI+ system. I usually do this in apps initialization and destruction (winmain or main if not mfc apps)
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
hInst = hInstance;
InitCommonControls();
DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DialogProc);
Gdiplus::GdiplusShutdown(gdiplusToken);
}
|
|
|
|
|
MFC by default support only BMP file, however you can take services of different library that suits your need, one of them is gdiplus, search Google for more information
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You've not shown the code that actually draws the image, but I'll take a guess at the problem. In your first code snippet, it is a CBitmap instance that will be used for drawing. In your second snippet, it is a pointer to a Bitmap instance that is used. Your drawing code will need to be adjusted accordingly.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
, basically my motive is to draw image (png/jpg) using bitblt...I will adjust code accordingly.
|
|
|
|
|
|
Thank you for help...I am able to draw image.
I need your help in one more problem as described below:
I need to draw image on the screen using XOR so that diff of 2 images can be draw as a complete image. How to solve this?
|
|
|
|
|
first you can get the path,then set ID and path link!
so,your first method can do it
|
|
|
|
|
Hi, I want 3 split windows in my application,in that left for Tree control and Right window act as a main window and bottom window have list control to show some log of my application. For that i made this code..
in Mainframe.cpp(), in OnCreateClient()
if(!m_SplitterWnd.CreateStatic(this, 2, 1))
return FALSE;
CRect rect;
GetClientRect(&rect);
if(!m_SplitterWnd.CreateView(1, 0, RUNTIME_CLASS(CBottomView), CSize(rect.Width(), 50), pContext))
return FALSE;
m_SplitterWnd.SetRowInfo(0, 800, 50);
m_SplitterWnd.SetRowInfo(1, 330, 50);
if (!m_SplitterWnd1.CreateStatic(&m_SplitterWnd, 1, 2, WS_CHILD | WS_VISIBLE | WS_BORDER |AFX_IDW_PANE_FIRST, m_SplitterWnd.IdFromRowCol(0,0)))
return FALSE;
if(!m_SplitterWnd1.CreateView(0, 0, RUNTIME_CLASS(CTreeMenuView), CSize(rect.Width()/5,rect.Height()-50), pContext))
return FALSE;
if(!m_SplitterWnd1.CreateView(0, 1, RUNTIME_CLASS(CMainWindowView), CSize(rect.Width()-rect.Width()/5,rect.Height()-50), pContext))
return FALSE;
int nWidth=rect.Width();
m_SplitterWnd1.SetColumnInfo(0, nWidth*0.25, 50);
m_SplitterWnd1.SetColumnInfo(1, nWidth*0.75, 50);
return CMDIFrameWnd::OnCreateClient(lpcs, pContext);
And i have to attach all my child window in right side window( CMainWindowView)..
In my app class,
pDocTemplate = new CMultiDocTemplate(IDR_MAINFRAME,
RUNTIME_CLASS(CABBHarmonyDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CMainWindowView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
pGraphViewTemplate = new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CABBHarmonyDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CGraphview));
AddDocTemplate(pGraphViewTemplate);
So when i press F5,this GraphView should display in MainwindowView.
But it does not appear.Whats the mistake i did? Pls help me..
in Mianframe.cpp
void CMainFrame::OnGraphview()
{
if( pGraphDisplayFrame == NULL )
{
CDocTemplate *pTemplate = theApp.pGraphViewTemplate;
CABBHarmonyDoc* pDoc = new CABBHarmonyDoc;
pGraphDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL );
if( pGraphDisplayFrame == NULL )
{
AfxMessageBox( "Unable to Create Graph Display" );
return;
}
pTemplate->InitialUpdateFrame( pGraphDisplayFrame,NULL );
}
else
MDIActivate( pGraphDisplayFrame );
}
When i debug, i found in winfrm.cpp,
void CFrameWnd::InitialUpdateFrame(CDocument* pDoc, BOOL bMakeVisible)
{
CView* pView = NULL;
if (GetActiveView() == NULL)
{
CWnd* pWnd = GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE); if (pWnd != NULL && pWnd->IsKindOf(RUNTIME_CLASS(CView)))
{
pView = (CView*)pWnd;
SetActiveView(pView, FALSE);
}
}
Here pWnd returns NULL. Whats the mistake pls help me out.
Anu
|
|
|
|
|
You are allocating a new uninitialized instance of your document in OnGraphView() and use it for creation of the new frame. You should replace the pDoc parameter by your existing document.
You may also move the OnGraphView() handler from the main frame class to your document class (passing then this for the document pointer). Because the graph can be only shown when a document has been loaded.
|
|
|
|
|
I have a bit of strange behavior with a MFC application that I haven't seen before.
The application is a simple MFC Dialog running unders Windows XP SP3 and using Visual Studio 2008. It builds fine under Debug and Release configurations. The Debug executable runs fine under the debugger and also within Visual Studio using the Start Without Debugging button. The Release executable runs fine directly from Windows.
However, the Debug executable does NOT run fine directly from Windows. When double clicked from Windows Explorer, there is a brief hourglass and then what appears to be a quick exit. No messages, no nothing. Adding a few AfxMessageBox calls to the app's CWinAppEx class, it appears that not only does the app's InitInstance method not get called, but even the CWinAppEx constructor does not get called. Obviously, this makes debugging the problem somewhat difficult.
Anyone seen similar behavior before? Seems like it might be a manifest problem of some sort, but I don't see why it would only affect the Debug executable and only directly from Windows.
Additional Info: With a little more testing, I found that this behavior occurs even in a simple test application as soon as I add any code that requires an internally developed DLL. Note that if I rename this DLL, I get the usual can't find the DLL message. So the app is finding the DLL, but for some reason, in Debug configuration, there's a problem only when running directly from Windows.
modified 8-May-12 14:47pm.
|
|
|
|
|
Does the "internally developed DLL" have any resources that are being used by the EXE or is it just exported functions that are being used?
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
modified 9-May-12 9:17am.
|
|
|
|
|
Do you have the sources/project for this "internally developped DLL"? If yes, try the following: load the project for the DLL, build it and hit F5, VS should ask you to specify the executable you want to test your DLL with (if it doesn't, you can specify that somewhere in the project settings, can't recall where now), browse for your exe, select it and let it run (make it so it will load the DLL you just built, like, placing the executable right next to the DLL) and see if there are any exceptions thrown, check the debugger's output window too for any hints, maybe you will see something useful.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Hello Experts,
I need to transfer image via Socket, somtimes image may be same or may somewhat similar.
I am trying to get diffrenece of images so that I can be sent faster via socket.
Image type is jpeg...Please suggest how to send min data of image?
|
|
|
|
|
john5632 wrote: I am trying to get diffrenece of images so that I can be sent faster via socket.
This may not be totally helpful, but it may help direct you.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
hello Friends
I come across to this situation first time and googled a lot but no Luck.
I am adding two multipleDocTemplates except their Document class is Different.
Now,I am opening a File using one Document template but I want to save that File using another Document template.
Where and how will i switch to another Doc Template so that when I save it uses another Doc template.
An Ideas??
Regards
Yogesh
|
|
|
|
|
I need some help with the jump physics example I found on the web.
The following code makes my character go up and down, but I have to press and hold down the arrow-up key on my keyboard.
I want my character to complete a full jump cycle without having to hold the arrow-up key down.
I want to be able to press down on the key once and release to do a complete jump.
Do I need to somehow include a do while loop? :confused
Thanks!
bool jumping;
const float step = 0.05f; const float limit = 1.0f;
if (GetAsyncKeyState(VK_UP)== TRUE) {
static float jump = 0.0f;
static float strength = limit;
if(jumping){
jump += step;
if(jump <= limit){
strength -= step;
player.y += (step * strength);
}
else{
strength += step;
if(player.y - (step * strength) <= 0.0f)){
player.y = 0.0f;
jumping = false; jump = 0.0f;
strength = limit; }
else{
player.y -= (step * strength);
}
}
}
}
|
|
|
|
|
OK, this code is posted "out of context" (it simply starts with the "if" statement, not how you got there).
A reasonable assumption given your problem statement is that this code is run as part of an "OnChar()" or other event *caused* by your holding a key down.
If that's the case, and you want to convert this to code that runs in a loop, you need to address two things.
1) what event starts the "jumping"?
2) what event stops the "jumping"?
Clearly, right now event 1) is you holding down a key, event 2) is when you let it go. Letting the key go is *not* an event, it's the absence of a key_down event. You'll need to figure out the "stop" event first.
|
|
|
|
|
Hi Chuck O'Toole,
thanks for the quick reply.
These are global variables:
bool jumping;
const float step = 0.05f;
const float limit = 1.0f;
And the rest of the code below is contained inside of my game rendering function. The jump code works when I press the arrow-key, it just does't work correctly.
BOOL StartGame ()
{
if (GetAsyncKeyState(VK_UP)== TRUE)
{
static float jump = 0.0f;
static float strength = limit;
if(jumping){
jump += step;
if(jump <= limit){
strength -= step;
player.y += (step * strength);
}
else{
strength += step;
if(player.y - (step * strength) <= 0.0f)){
player.y = 0.0f;
jumping = false;
jump = 0.0f;
strength = limit;
}
else{
player.y -= (step * strength);
}
}
}
return TRUE;
}
|
|
|
|
|
If I got you: use a tristate variable instead of a boolean, say jump_state .
enum JumpState
{
JS_IDLE,
JS_START,
JS_JUMPING
};
jump_state = JS_IDLE;
if (GetAsyncKeyState(VK_UP) == TRUE)
if (jump_state == JS_IDLE)
jump_state = JS_START;
else
if (jump_state == JS_START)
jump_state == JS_JUMPING;
if ( jump_state == JUMPING)
{
if ( landed )
jump_state == JS_IDLE;
}
Veni, vidi, vici.
|
|
|
|
|
|
Thank you.
Veni, vidi, vici.
|
|
|
|
|
Hey guys,
thanks again for y'alls help. I got it working now. You guys are great!
|
|
|
|
|
You are welcome.
Veni, vidi, vici.
|
|
|
|
|