|
|
Don't forget the developer's best friend: your debugger. Using it in that situation would immediately reveal that there's something wrong with the parameters that are passed to your callback function.
|
|
|
|
|
Hello All,
I am trying to insert a BMP image in to picture control.
I have added Microsoft common dialog control Ver6 ActiveX control.
IDC_COMMONDIALOG1 Type :- CcommonDialog1 Member:- m_com
Picture Control:-
IDC_STATIC1 Type :- CStatic Member:- m_st1
I have show button in the dialog, when the we click on that we can select a BMP file and show the same file in the Picture control in the dialog.for that i have used the below code.
void CImageAppDlg::OnShow() <br />
{<br />
<br />
<br />
<br />
CString file;<br />
file.Empty();<br />
m_com.ShowOpen();<br />
file=m_com.GetFileName();<br />
file.TrimRight();<br />
<br />
<br />
if(m_hBmpNew != NULL )<br />
DeleteObject(m_hBmpNew);<br />
sourcex=sourcey=0;
if(file.IsEmpty())<br />
AfxMessageBox("Please Select a picture file");<br />
else{<br />
if(file.Right(3)!="bmp")<br />
AfxMessageBox("Please Select a .bmp file");<br />
else<br />
{<br />
m_hBmpNew = (HBITMAP) LoadImage(<br />
AfxGetInstanceHandle(), <br />
file, <br />
IMAGE_BITMAP, <br />
0, <br />
0, <br />
LR_LOADFROMFILE); <br />
if( m_hBmpNew == NULL ){<br />
AfxMessageBox("Load Image Failed");}<br />
<br />
else{<br />
m_st1.GetClientRect( &rectStaticClient );<br />
rectStaticClient.NormalizeRect();<br />
m_size.cx=rectStaticClient.Size().cx;<br />
m_size.cy=rectStaticClient.Size().cy;<br />
m_size.cx = rectStaticClient.Width();
m_size.cy = rectStaticClient.Height();
<br />
<br />
m_st1.ClientToScreen( &rectStaticClient );<br />
ScreenToClient( &rectStaticClient);<br />
<br />
m_pt.x = rectStaticClient.left;<br />
m_pt.y = rectStaticClient.top;<br />
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );<br />
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMem, m_hBmpNew ) );<br />
<br />
offsetx= m_pt.x;<br />
offsety=m_pt.y;<br />
if(m_bmInfo.bmWidth<=m_size.cx)<br />
{<br />
if((m_size.cx-m_bmInfo.bmWidth)==0)<br />
offsetx= m_pt.x;<br />
else<br />
offsetx= m_pt.x+((m_size.cx-m_bmInfo.bmWidth)/2);<br />
<br />
}<br />
else<br />
if(m_bmInfo.bmHeight<=m_size.cy)<br />
{<br />
if((m_size.cy-m_bmInfo.bmHeight)==0)<br />
offsety= m_pt.y;<br />
else<br />
offsety= m_pt.y+((m_size.cy-m_bmInfo.bmHeight)/2);<br />
}<br />
else<br />
<br />
InvalidateRect(&rectStaticClient);<br />
}<br />
}<br />
}<br />
<br />
}<br />
code has no errors but in the run time i am getting this error
Microsoft VC++ Debug Library
Debug Assertion Failed Error
Can u please tell me what is cause for the error ??
Thanking you ...
Pruthvi R.
|
|
|
|
|
You can use of LoadImage for load your bmp file or CImage class for other foramats and then use of SetBitmap(HBITMAP).
|
|
|
|
|
Hi Hamid,
Thanks for the response.
I have used the LoadImage function only, but still i am getting the run time error. can u please tell me what is the cause.. ?
|
|
|
|
|
Can you show your code now :
HBITMAP h=(HBITMAP)LoadImage(...);
m.SetButton(h);
Does your code like this?
|
|
|
|
|
Hamid i am unable to understand , can u please have a look at my first post where i have posted my complete code ?? and please let me know what changes i have to make.
|
|
|
|
|
Ok run this code did you see any thing on the monitor
//header file
#include "atlImage.h"
CStatic m_Static;
m_Static.Create(NULL,WS_VISIBLE|WS_CHILD|SS_BITMAP,CRect(0,0,100,100),this);
CImage m;
m.Load(_T("d:\\1234.bmp"));
m_Static.SetBitmap(m.Detach());
|
|
|
|
|
|
Hi,
I'm using MFC Visual C++ and encountered a problem using OnKeyDown() function. The problem is that I don't get response from keyboard even if I included all the requirements.
MyDlgClass.cpp
......
......
ON_WM_KEYDOWN
......
......
void CMyDlgClass::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
................
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
I think, the problem is that the focus wasn't on the dialog but on other objects. If I'm correct how can I possibly shift focus to the dialog or get response from the keyboard?
Hope somebody can help me, thanks.
}
|
|
|
|
|
Do you have any controls on the dialog?
|
|
|
|
|
Hamid. wrote: Do you have any controls on the dialog?
Yes, CButtons and CEdit controls.
|
|
|
|
|
So you can use of PreTranslateMessage.
|
|
|
|
|
Ok, Thanks a lot.
I'll try this.
|
|
|
|
|
You can use of those events,but you dont have any control on the dialog.
|
|
|
|
|
Using a Microsoft Spy++, I can identify a "Class Name" of any application.
For example, the class name of Notepad.exe is "Notepad".
At this moment, I want to modify a "Class Name" of some applications.
Is it possible or not? If possible, how can I modify a class name?
Thanks!
|
|
|
|
|
what weird hacking are trying to achieve here sir ?
|
|
|
|
|
The question is nothing but a question.
If there are open ways, it is no more weird.
|
|
|
|
|
Wormhole5230 wrote: The question is nothing but a question.
Black Hat intern, Huh?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
You need the "little hacker guide" for the purpose.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
comment ecrire une application pour téléphoner avec un mobile via le pc
|
|
|
|
|
1) speak english, even if some of us can understand french
2) read the posting guidelines
3) don't expect us to write the whole code for you. YOU have to work first, and ask for a specific point if you're stuck.
good luck then
|
|
|
|
|
Can you translate your question for us?
|
|
|
|
|
it means : "How to write an application to telephone with a mobile phone thru PC"
how crappy request, isn't it ?
BTW, how are you hamid ? long time no talk, hey !
|
|
|
|
|
Thanks, yeah long time (of january) of course I never forget friends like(you,ThatAlok,DavidCrow,Pallini and other) BTW yesterday I was watching series TV and I remembered you("knot monte cristo" a serial of french)
|
|
|
|