|
This code should work correctly on Windows 98. Is it working?
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"
|
|
|
|
|
When I run this code on window 98 I press button 1 it will not come out any bitmap pictuce but when I run on Windows Xp it will come out the bitmap picture. So I don't know where my problem.
|
|
|
|
|
I really don't know if this could be the problem but perhaps give it a try:
Best Friend wrote:
...
else if (nIDEvent == 2)
{
CBitmap m_bmp;
m_bmp.LoadBitmap(IDB_BITMAP2);
m_bitmap.SetBitmap(m_bmp);
KillTimer(2);
SetTimer(1, 500, 0);
}
I think it's better to make a KillTimer(1); before setting it again. Perhaps Win98 got a problem with this.
I don't know the structure of your application but for the timer1-branch I would also suggest to KillTimer(1); because you restart this timer in timer2-branch. So my solution would be:
if (nIDEvent == 1)
{
CBitmap m_bmp;
m_bmp.LoadBitmap(IDB_BITMAP1);
m_bitmap.SetBitmap(m_bmp);
KillTimer(1);
KillTimer(2);
SetTimer(2, 500, 0);
}
else if (nIDEvent == 2)
{
CBitmap m_bmp;
m_bmp.LoadBitmap(IDB_BITMAP2);
m_bitmap.SetBitmap(m_bmp);
KillTimer(2);
KillTimer(1);
SetTimer(1, 500, 0);
}
Regards, mYkel
|
|
|
|
|
It still can not popup the bitmap picture. I has to read the MSDN on that he say LoadBitmap need to Import library User32.lib.
|
|
|
|
|
I also looked up the method in MSDN but couldn't find anything that says something about linking to user32.lib. Anyway, I found two very interesting links for you which should solve your problem.
At first try this one:
PRB: CStatic::SetBitmap Doesn't Display Bitmap on Win NT 3.51
Last reviewed: July 10, 1997
Article ID: Q151378
<a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;151378">http://support.microsoft.com/default.aspx?scid=kb;en-us;151378</a>[<a target=_blank title='New Window' href="http://support.microsoft.com/default.aspx?scid=kb;en-us;151378">^</a>] If that doesn't work either you have to do it like described here:
SAMPLE: Drawing a Bitmap in a Foundation Class Dialog Box
Last reviewed: October 23, 1998
Article ID: Q141863
<a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;141863">http: The latter is a little bit more complicated but it works to 100%. I use this way of painting bitmaps in lots of my projects
Regards, mYkel
|
|
|
|
|
why are windows in some softwares (which I think are written in delphi) like CONTEXT(the editor) or UMPS(8051 and other microcontrollers simulator) are very different to ones written in vcpp.
does different languages offer different ways to make a window look different.( i hope u understand this sentence)
|
|
|
|
|
different styles,
u can make VC windows look like VB form windows very easily
|
|
|
|
|
Hi
I badly need a chart within an application that i am building. It should accept values from the database and draw lines but however, i was faced with a major problem, LACK OF DOCUMENTATION. Can somebody, please, help me to implement a simple bar char in visual c++ 6.0.
Thank you for your precious help.
I really need this stuff quick.
Krugger
|
|
|
|
|
|
hi,
im looking to get access to the data in the main parent window dialog from another dialog,
i need a pointer to the main window ?
can someone give me exact code,
as i asked this before and was given instructions and
not concencrate help
|
|
|
|
|
You can try with
AfxGetMainWnd()
|
|
|
|
|
that returns a pointer to desktop
|
|
|
|
|
you need to pass the "main parent window" pointer to the other dialogs.
if you are creating the other dialogs from the parent dialog do something like :
{
CAnotherDialog dlg;
dlg.pParentDialog = this;
dlg.DoModal();
}
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
I have a data file that has info as show below.
What is the best way to retrive info only the email addresses. In VC++ 6.0, How can I read a data file by lines?
------- Data file begin -----------
From: "test1 at yahoo" <test1@yahoo.com>
Subject: Follow Up Research
To: "Someone at yahoo" <someone@yahoo.com>, "Someone at Microsoft"
<someone@ms.com>, "Someone at Lycos" <someone@lycos.com>
Cc: "Someone2 at yahoo" <someone2@yahoo.com>, "Someone2 at Microsoft"
<someone2@ms.com>, "Someone2 at Lycos" <someone2@lycos.com>
Content-Type: multipart/mixed; boundary="=_NextPart_2rfkindysadvnqw3nerasdf"
--------------- End here
|
|
|
|
|
sysmatrix wrote:
In VC++ 6.0, How can I read a data file by lines?
CStdioFile::ReadString()
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I am using ODBC 3.0 to connect to Microsoft Access Database, using ODBC functions like SQLFetch() and likes....
The data enters the database successfully but while retrieving date for no reasons Month and Year are going hayways....
the code being
HSTMT hstmt;<br />
SQLRETURN sr;<br />
SQLCHAR SQL[] = "SELECT DONumber, RelDate, Validity FROM DODetails";<br />
char mess[500];<br />
strcpy(mess,"Fetch:\n");<br />
<br />
sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);<br />
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)<br />
displayError(sr, "Error in Allocating Handle to Statement");<br />
<br />
sr = SQLExecDirect(hstmt, SQL, SQL_NTS);<br />
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)<br />
displayError(sr, "Error in Executing the Statement");<br />
<br />
<br />
sr = SQLBindCol(hstmt,1,SQL_C_TCHAR,<br />
don.donum,sizeof(don.donum),&don.dolen);<br />
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)<br />
displayError(sr, "Error in Bind 1");<br />
<br />
sr = SQLBindCol(hstmt,2,SQL_TYPE_DATE,<br />
&don.reldate,sizeof(don.reldate),&don.relen);<br />
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)<br />
displayError(sr, "Error in Bind 2");<br />
<br />
sr = SQLBindCol(hstmt,3,SQL_INTEGER,<br />
&don.valid,sizeof(don.valid),&don.valen);<br />
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)<br />
displayError(sr, "Error in Bind 3");<br />
<br />
<br />
while(SQLFetch(hstmt) == SQL_SUCCESS)<br />
{<br />
sprintf(mess,"%s\tName : %s \tRel Date : %s \t Validity : %d\n",mess,don.donum,(LPCTSTR)don.reldate.Format("%d/%m/%Y"),don.valid);<br />
<br />
}<br />
<br />
MessageBox(mess);<br />
SQLFreeHandle(SQL_HANDLE_STMT,hstmt);<br />
Also got some trouble using the CMonthCalCtrl...again the problem being the date turns out to be wrong everytime...
All help will be appreciated;)
|
|
|
|
|
hello,
i am developing an addin for outlook to insert an image to outlook email body but my problem when i insert image on top of a text (using DOM) the text splits into two sides and image got placed between the text but this is not allowed i have to place image on top of the text without the splitting. Is there any way in VC++,COM,DHTML.
|
|
|
|
|
I find that Graphics::DrawImage performs better when its first parameter is an instance of Image than that of Bitmap. This makes me confused:
this code fragment:
Image image(L"C:\a.jpg");
Rect rect(0,0,100,100);
g.DrawImage(&image,rect);
and this one:
Bitmap bmp(L"C:\a.jpg");
Rect rect(0,0,100,100);
g.DrawImage(&bmp,rect);
and the result is that the first one performs much better when i deflate the "rect" object.
Can any one explain this?
In my application, I read image data from an HBITMAP handle not a file,so Bitmap is preferred, but as you can see above,i need an Image object to display the image.So how can i convert a Bitmap instance to an Image instance. The type cast won't help and I have also tried Bitmap::GetThumbnailImage. And another way is to use IStream, but i am really not good at using it.
Thanks.
|
|
|
|
|
ok, i need another way to test if caps lock is on or off, i tried doing
GetKeyState(VK_CAPITAL) but it doesnt work out too well. is there another method or function i can use to test if caps lock is on or off?
Compiler: VC++ 6 Enterprise
|
|
|
|
|
|
Hello,
I have a few questions regarding Memory Management in Visual C++. I am using Visual Studio .NET 2002 and as a sidenote I am creating a Win32 application that uses the DirectX API. I am compiling in Debug mode (not Release). If I create a Class, I generally make a constructor and destructor for each class. I know the constructor is called when the user creates (instantiates) a class object. When is the destructor called?
Do I need to do something to my class object to call the destructor? Or is this automated somehow?
Also, I want to be sure I don't have any memory leaks (releasing all COM objects and freeing all pointers). How do I specifically check to see that I have successfully done so in Visual Studio .NET?
Thank You,
CBerg
|
|
|
|
|
the destructor will be called when an object leaves its living scope,for example function returning. You should not try to call it directly,or the comiler may complains about that because it knows when to call the destructor. You should read some C++ textbooks to gain more about C++.
the second one: the return type of all COM interfaces is HRESULT,which is a 32bit integer. The first bit of it indicates whether an operation succeeded or failed: 0 for success and 1 for fail,so if the returing value is less than 0, you can know that the operation failed,otherwise success. Usually you can use the following macro which is defined in the Winerror.h:
#define SUCCEEDED(Status) ((HRESULT)(Status) >= 0)
#define FAILED(Status) ((HRESULT)(Status)<0)
but for the IUnknown::Release,you should always get S_OK result.
|
|
|
|
|
Hi,
Just to add to what exRange said. If you allocate objects on the heap (through the keywork 'new'), then you are responsible for freeing the memory by calling delete. Generally, it is a good idea to allocate resources in the constructor and make sure they are freed in the destructor.
Keith
|
|
|
|
|
Essentially, there are three ways to create an object:
class Object {
public:
Object();
~Object();
};
Object GlobalObject;
void Function()
{
Object StackObject;
Object *HeapObject = new Object;
delete HeapObject;
} First, we have a class Object , with a constructor and a destructor. There are three instances of the class in the code: GlobalObject , StackObject , and HeapObject (which is a pointer).
Since GlobalObject is at file scope, the constructor for GlobalObject is called by the C++ runtime when the program starts, and its destructor when the program exits.
StackObject is created on the stack, inside the function Function . It's destructor is called when Function() exits. More precisely, the destructor is called when execution leaves the enclosing scope (the outermost braces "{" "}" of the function).
HeapObject is a pointer to an Object allocated on the heap using the new operator. In this case, the user (you the programmer) must explicitly destroy the object using the delete operator. The delete operator calls the destructor.
COM objects are slightly different. You 'allocate' COM objects using CoCreateInstance or one of the related functions, which return an interface pointer. All COM interfaces derive from the IUnknown interface, which has three methods: AddRef , Release , and QueryInterface . When you are done using a COM object, you release it by calling the Release method through its interface pointer.
Software Zen: delete this;
|
|
|
|
|