|
Hi,
How can I create a program that it has a staus symbol as tray icon and never became hide when user doesn't activate it in XP OS?
thank
|
|
|
|
|
Hello,
I am having a problem using the LoadLibrary function. I am running into heap corruption during the call. The error I am getting is an assert of _CrtCheckMemory() in dbgheap.c.
I created the DLL with the flags MTd and LDd in the command line and I am loading it from an executable created using the Multi-Threaded Debug RTL.
Does anyone know of another way that this function call may cause heap corruption?
Stumped,
John
|
|
|
|
|
Check the global (static) valuables in the DLL. Before the actual assertion there is first chance exception, you can find the exact number from the output window. When you know first chance exception, you can probably intercept it (Ctrl+Alt+E) and see the actual function that does that.
|
|
|
|
|
I'm afraid that I don't quite know what you mean. I should also mention that this does not happen if I invoke the debugger. It only happens when I run without debugging which makes it difficult to determine exactly what is happening.
There are no global static variables directly in my source code and I cannot find any in any of the included headers.
My DLLMain simply returns true.
I know it is happening during the call to LoadLibrary because the assertion occurs before LoadLibrary returns.
Unfortunately, I have very little experience with dlls and so this is all quite new to me.
Thanks,
John
|
|
|
|
|
Check your code. Here is a tutorial on DLL.
http://www.flipcode.com/tutorials/tut_dll01.shtml
Kuphryn
|
|
|
|
|
I triend to go through this tutorial: http://www.codeproject.com/dialog/bmpdlg01.asp. However, it is for MSVC++.net. So therefore it will not work with my version of MSVC++. I was wondering how I would change the bg of a dialog either in MFC or in C++.
If anyone could help me then it would be greatly appreciated.
orcblood
|
|
|
|
|
Do the following...
// 1. Add a CBrush member function...
CBrush mBrush;
----------
// 2. In OnInitDialog...
//Load the bitmap from a file and create patterned brush.
RECT rc;
GetClientRect(&rc);
HBITMAP hBmp=NULL;
hBmp=(HBITMAP)::LoadImage(NULL,"c:\\YourImagePath\\TheBitmap.bmp",IMAGE_BITMAP,rc.right,rc.bottom,LR_LOADFROMFILE);
CBitmap *pBmp=CBitmap::FromHandle(hBmp);
m_brush.CreatePatternBrush(pBmp);
::DeleteObject(hBmp);
----------
// 3. In OnPaint...
//Paint the background with the image brush
CRect rcClient;
GetClientRect(&rcClient);
dc.FillRect(&rcClient,&m_brush);
---------------
// 4. In OnCtlColor..
// You need to do this to keep any static text controls on your
// dialog from painting a default dialog background under the static field.
switch(nCtlColor)
{
case CTLCOLOR_STATIC:
pDC->SetTextColor(RGB(....)); //Set your text color.
case CTLCOLOR_BTN:
pDC->SetBkMode(TRANSPARENT);
case CTLCOLOR_DLG:
hbr=m_brush;
}
----------------
Art
|
|
|
|
|
Hi,
i just implemented a freeware serial port OCX in
my program .... it runs perfectly !! (RSComm)
Now i want to run it on another comp.
Then the old problem occours
The program need the ocx file and some dll`s ....
Who can tell me where i can build ALL the
things needed by the program in ONE binary file ?
(i activated this in the mfc-wizard on beginning)
every hint is welcome
by the way: this can work! in another, ready
program, i saw some other ocx windows and
this program is ONE file ....
|
|
|
|
|
I'm trying to override vector's operator[] but am getting multiple errors. I have an array object derived from vector. The operator[] of vector does not check for an invalid object and always returns a pointer of the object type stored in the object regardless of whether or not that object actually exists in the array. MSDN says "If that position is invalid, the behavior is undefined". Ok, I'll buy that but that causes alot of problems in my programs that will use it cuz then I'd have to check for invalid parameters each time I call it when I'd rather do the check in the array of type vector object itself.
For example, if I have 3 objects in my derived array class and ask it to return a pointer to the 4th object in the array, or ask it to return a reference to the -1 element, it will. Slightly modified example below:
class CMyArray : public vector<CMyObject>
{
public:
CMyArray() : vector<CMyObject>()
{
}
};
I added the following code to above but get several errors, of course.
CMyObject& operator[](size_type pos)
{
if(pos < 0)
return NULL;
if(pos > size())
return NULL;
return vector::operator[pos];
};
The errors for the two if's returning NULL are:
C:\Scratch Code\myobject.h(172) : error C2440: 'return' : cannot convert from 'const int' to 'class CMyObject&'
Which I expect but really don't no what else to return to indicate an invalid index, object, or position. As for the last statement, I've gotten different errors depending on how I coded it. Don't know what's right. I've tried vector::operator[](pos) but gives me error about "ambigious call to overloaded function."
Thanks
|
|
|
|
|
NULL is a pointer, not a reference to CMyObject , so it's no wonder the compiler complains. Your only option here (to the best of my knowledge) is to throw an exception.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You might consider using the "at" function in vector instead. That function does bounds checking. That way you wouldn't have to do any specialization. "at" may throw so be sure to put the call in a try .. catch block.
PS. When checking your bounds as in your snip-it above, I think you want (pos >= size()) as your second fail condition since size() is 1 too many.
|
|
|
|
|
You're right about the (pos >= size()). I looked into at() and it looks like it will work fine. Thanks, guys!
|
|
|
|
|
Hi all!
I want to create a large bitmap, draw on it and then just display a portion of it (there is a scrolling feature in my app).
When I use the code below and set the 'picwidth' to i.e. 1000, it works just fine.
But when I set the width to i.e. 5000 just a black bitmap appears, without the white line.
There is NO error at 'CreateCompatibleDC' and 'CreateCompatibleBitmap' !
CBitmap bmp;
CDC dc2;
CClientDC dc(this);
int picwidth = 5000;
if (!dc2.CreateCompatibleDC(&dc)) {
AfxMessageBox("error");
return FALSE;
}
if (!bmp.CreateCompatibleBitmap( &dc, picwidth,512)) {
AfxMessageBox("error");
return FALSE;
}
CBitmap* oldbmap=dc2.SelectObject(&bmp);
CPen pen( PS_SOLID, 0, RGB(255,255,255));
CPen* pPenOld = dc2.SelectObject( &pen );
int nMap = dc2.SetMapMode( MM_TEXT );
for (i=0;i<picwidth;i++) {
dc2.MoveTo( i, 300 );
dc2.LineTo( i, 300 );
}
dc2.SetMapMode( nMap );
dc2.SelectObject( pPenOld );
pDC->BitBlt(5,5, 600 , 512 ,&dc2,0,0,SRCCOPY);
dc2.SelectObject(oldbmap);
Is there anything wrong in my code ?
What can I do that the 5000 pixel wide bitmap is created successfully ?
Thank you very much in advance!
Best regards,
Hannes / Austria.
|
|
|
|
|
There *is* a physical limit to bitmap size, and I reckon you've crossed it.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
what's the return value of the SelectObject?
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
Hi Chris!
Which one do you mean ?
The last one ?
dc2.SelectObject(oldbmap);
..with
szMsg.Format(" %d", dc2.SelectObject(oldbmap));
AfxMessageBox(szMsg);
I get: 61047404
Thank you,
Hannes.
|
|
|
|
|
the first one, the one that selects the huge bitmap into the DC.
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
Good morning
The return values for
CBitmap* oldbmap=dc2.SelectObject(&bmp);
are:
4423188 if the bitmap creation succeeds (width = 1000)
4423204 if something goes wrong (width = 5000)
Thank you very much!
Best regards,
Hannes.
|
|
|
|
|
what is the return value from the BitBlt ?
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
Hi Chris!
Just came home from work...
I checked the return values from BitBlt and I get a 1 in both cases.
It's not surprising since the bitmap is actually drawn, but it is just black. (without the white line)
Thank you very much for working on this with me!
Very much appreciated!!!
Best regards,
Hannes / Austria.
|
|
|
|
|
Hi:
I have a matrix class and I would like to be able to fill in the elements by supplying a list of values. In other words, I would like to be able to write something like this:
matrix A(2, 2) = {3, 4; 2, 1};
This would create a 2 x 2 matrix:
3 4
2 1
Is this possible? The only workaround that I can think of right now is to convert the right hand side to a string "3, 4; 2, 1" and then overload the assignment operator with something like this:
matrix& operator = ( char *sString );
And then do a whole bunch of splits, trims, and searches within the string.
Can anyone suggest a better solution?
Thanks
|
|
|
|
|
of course it's possible!
int a[2][2] = { {1,2} , {3,4} };
#include <beer.h>
|
|
|
|
|
The thing is that I am assigning this array to a class, which has variables other than the 2-dimensional array or numbers (I don't think shallow assignment will do here):
class matrix
{
private:
double **_m;
double *_v;
int _nType, _nRows, _nCols;
void _Copy( const matrix &m1 );
void _Destroy( );
public:
// Default constructor
matrix( int nMatrixType = mxMatrix, int nDim1 = 0, int nDim2 = 0 );
// Copy constructor
matrix( const matrix &m1 );
~matrix( );
matrix& operator = ( const matrix &m1 );
matrix operator * ( const matrix &m1 );
int GetType( ) { return _nType; }
int GetRows( ) { return _nRows; }
int GetCols( ) { return _nCols; }
void Display( ) const;
double GetElement( int nDim1, int nDim2 = 0 ) const;
void SetElement( double fValue, int nDim1, int nDim2 = 0 );
matrix Transpose( );
matrix Solve( const matrix &mRHS );
};
|
|
|
|
|
Does your design require dynamic allocation? In other words, does the program dynamically allocate matrices during run-time? If not, one solution is an STL container such as a list of paired values.
Kuphryn
|
|
|
|
|
The program DOES allocate matrices dynamically; however, there is going to be a fixed 9 x 9 matrix with predetermined values that is going to be used in calculations (this matrix needs to be of the same type (class) as the other dynamically allocated matrices). I just want to avoid typing the following 81 times:
m.SetElement(0, 0, 100.0);
m.SetElement(0, 0, 200.0);
.....
and replace it with something like m = { 100.0, 200.0, ... }
Thanks.
|
|
|
|