|
Okay.
See if you can pass in a const string and return the modified string instead of void.
Kuphryn
|
|
|
|
|
That's usually caused by the build settings for the LIB using one form of CRT linking (static or DLL) and the executable using the other.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
in my OnPaint, i am drawing to a memory DC, then blitting to the screen. if i do memDC.DrawFocusRect(...), then Blt, the rectangle turns out light blue (ie. wrong). but if i Blt then draw the focus rect onto the screen DC, it comes out black-and-white dashed (as it should).
memDC.DrawFocusRect(CRect(10,10,100,100));
dc.BitBlt(frameRect.left, frameRect.top, frameRect.Width(), frameRect.Height(), &memDC, 0,0, SRCCOPY);
memDC.SelectObject(ob);
dc.DrawFocusRect(CRect(10,10,100,100));
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
play around with SetTextColor and SetBkColor for that device, i'm not exactly sure which parameters you'll need but changing those affects the focus rect
- Roman -
|
|
|
|
|
Is the mem DC's setup exactly the same as the screen DC?
|
|
|
|
|
i think it is...
CPaintDC dc(this);
CDialog::OnPaint();
CDC memDC;
if (memDC.CreateCompatibleDC(&dc))
{
CBitmap bmp;
if (bmp.CreateCompatibleBitmap(&dc, frameRect.Width(), frameRect.Height()))
{
CBitmap *ob = memDC.SelectObject(&bmp);
if (ob)
{
... draw the stuff in here
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
This suggestion may be silly, but worth the try: initialize the memDC before calling CDialog::OnPaint() . Something like:
CPaintDC dc(this);
CDC memDC;
BOOL bCreated = memDC.CreateCompatibleDC(&dc);
CDialog::OnPaint();
if(bCreated)
{
...
}
Good luck!
|
|
|
|
|
Try this int the Blt SRCINVERT
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
how do i make it so that i can display mathematical equations with symbols like square root, pi, fractions, etc. in my programs?
i know of Microsoft Equation Editor, but i cannot find an SDK for it nor can i insert it as a component in VB.NET. it would also be nice to do this in C++
if any of you know how, or know of other equation displaying packages available, please reply or send me an email
- Roman -
|
|
|
|
|
Roman Nurik wrote:
how do i make it so that i can display mathematical equations with symbols like square root, pi, fractions, etc. in my programs?
You write a layout engine for a word processor...
No, I'm serious. This is heavy layout stuff, not something I'd expect "just anyone" to get right.
If you just want to "do" this, I'd say your best bet is something like LaTex.
++luck;
|
|
|
|
|
|
Hi, folks!
I want a combobox that will always display the same items regardless of where I use it, so I thought about having it be its own class, inheriting from CComboBox. Rather than remember to add the items to it in the InitDialog function for each dialog box I use it in, I want the list to fill itself when it gets created. That way, I can drop a combobox onto a dialog, then change its type from CComboBox to CMyComboBox in the class header and I'm good to go.
So, at what point in the combobox's creation sequence is the best place to put my loading function? (I'm hoping the answer will be something analogous to the InitDialog override for a dialog box class.)
(To clarify things a bit, I'm loading the list from a file, so I can't create the list items in the Resource editor.)
Thanks!
Jesse
|
|
|
|
|
Why not override OnCreate for this? Let the base class handle the initialization chores and, on return, you will have a created window ready to accept AddString s.
|
|
|
|
|
Hmmm... Well, that doesn't seem to work.
I used ClassView to add a Windows Message Handler for WM_CREATE to my new ComboBox class, but the function never gets called.
M$VC added the following to my header:
protected:
//{{AFX_MSG(CRosPartNumberCB)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
and the following to the source:
BEGIN_MESSAGE_MAP(CRosPartNumberCB, CComboBox)
//{{AFX_MSG_MAP(CRosPartNumberCB)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRosPartNumberCB message handlers
int CRosPartNumberCB::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CComboBox::OnCreate(lpCreateStruct) == -1)
return -1;
AddString ("This is a test");
SelectString (-1, "This is a test");
return 0;
}
yet, a breakpoint on the above handler function never trips.
What am I missing here to get the connection established?
Jesse
|
|
|
|
|
If you are using the control in a dialog, the WM_CREATE message is not sent to controls created with a dialog template. You have to override the PreSubclassWindow() function and do your initialization there. Or better yet, have an initialization function that you call from both OnCreate() and PreSubclassWindow() , that way your control will work both ways.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Learning is a continuous process. Thanks, PJ.
|
|
|
|
|
PJ,
Thanks for the insight! Yes, I was using the control in a dialog template. After overriding the function you mentioned, all is working as I wished.
Jesse
|
|
|
|
|
I've got this MFC7 app I made in VS.NET and I can't get it to work right on a Win98 machine. I have a feeling I'm missing some files since VS.NET isn't installed on that machine and it is on my others. I have only tested it on WinXP so far and it all worked.
I'm using GDIPlus and MFC so I'm copying these files into my app directory: gdiplus.dll, mfc70.dll, mfc70u.dll, msvcr70.dll. I made a little setup project that uses the gdi, mfc and crt merge modules to copy these files in.
The app runs, but one of the list boxes (CListBox) is non-functional and another one works fine. Also, it adds a system tray icon but that isn't showing up in win98 either.
What's the deal?!
Fed up with MS crap! "You must be the change you wish to see in the world." - Gandhi
articles profile
|
|
|
|
|
Could it be a problem with the common controls? Try installing the latest version of Internet Explorer -- it the problem disappears most likely it is a common controls thing.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I believe I have IE6 installed on that machine. I'll check in the morning.
Jason Henderson "You must be the change you wish to see in the world." - Gandhi
articles profile
|
|
|
|
|
I need help saving large formatted text to an Oracle database. I am currently using CLOB data type in Oracle and a CRichEditCtrl control to stream the data in and out (StreamIn, StreamOut). I got an error message when the text is more than 124 lines (default Microsoft Word document setting). Please advise.
-Elizabeth
Eilzabeth
|
|
|
|
|
A CLOB should be able to hold about 2 Gig (?) of data. How are you inserting it?
Have you looked at the DBMS_LOB package?
Dave.
|
|
|
|
|
Oracle CLOB holds upto 4 gigabytes data. I tried retrieving the data out using StreamIn to a CRichEditCtrl control. I am able to StreamIn and StreamOut when data is upto 1 MB (I guess). I believe there are some tricks with large data in CLOB fields. I also checked Oracle DBMS_LOB package. It is not very clear how data can be retrieved to an program interface. CLOB data is stored and retrieved in the database by using locator ids. Have you successfully implemented an interface to work with large text data?
|
|
|
|
|
I am trying to implement a class for matrix multiplication:
Here is my header file:
******************************************************8
#include <stdlib.h>
class matrix
{
private:
double **m;
int nRows, nCols;
public:
matrix( int n1 = 0, int n2 = 0 );
~matrix( );
matrix& operator = ( const matrix& m1 );
matrix operator * ( const matrix& m1 );
int GetRows( ) { return nRows; }
int GetCols( ) { return nCols; }
void SetElement( int nRow, int nCol, double fValue );
double GetElement( int nRow, int nCol );
};
*********************************************************8
Here is my implementation file:
*****************************************************
#include "stdafx.h"
#include "matrix.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
matrix::matrix( int n1, int n2 ) {
if( n1 >= 0 && n2 >= 0 ) {
printf("Constructor ...\n");
nRows = n1;
nCols = n2;
if( nRows > 0 ) {
register int nRow;
m = ( double ** ) malloc( nRows * sizeof( double * ) );
for( nRow = 0; nRow < nRows; nRow++ ) {
m[nRow] = ( double * ) malloc( nCols * sizeof( double ) );
}
}
} else {
nRows = 0;
nCols = 0;
}
}
matrix::~matrix( ) {
if( nRows > 0 ) {
while( --nRows > -1 ) {
free( m[nRows] );
}
free( m );
}
}
matrix& matrix::operator = ( const matrix& m1 ) {
printf("Assignment operator ...\n");
// If the dimensions of the matrix are not the same, redefine the matrix
if( nRows != m1.nRows || nCols != m1.nCols ) {
printf("Reshaping!");
if( nRows > 0 ) {
while( --nRows > -1 ) {
free( m[nRows] );
}
free( m );
}
nRows = m1.nRows;
nCols = m1.nCols;
if( nRows > 0 ) {
register int nRow;
m = ( double ** ) malloc( nRows * sizeof( double * ) );
for( nRow = 0; nRow < nRows; nRow++ ) {
m[nRow] = ( double * ) malloc( nCols * sizeof( double ) );
}
}
}
// Copy the elements of the matrix
register int n1, n2;
for( n1 = 0; n1 < nRows; n1++ ) {
for( n2 = 0; n2 < nCols; n2++ ) {
***********************************
* THIS IS WHERE IT FAILS !!!!
***********************************
m[n1][n2] = m1.m[n1][n2];
}
}
return *this;
}
matrix matrix::operator * ( const matrix& m1 ) {
if( nCols == m1.nRows ) {
double fValue;
register int n1, n2, n3;
matrix mResult( nRows, m1.nCols );
for( n1 = 0; n1 < nRows; n1++ ) {
for ( n2 = 0; n2 < m1.nCols; n2++ ) {
fValue = 0.0;
for ( n3 = 0; n3 < nCols; n3++ ) {
fValue += m[n1][n3] * m1.m[n3][n2];
}
mResult.m[n1][n2] = fValue;
}
}
printf("Finished multiplying ...\n");
return mResult;
} else {
printf("ERROR");
// Multiplication is impossible
}
}
void matrix::SetElement( int nRow, int nCol, double fValue ) {
if( nRow >= 0 && nRow <= nRows && nCol >= 0 && nCol <= nCols) {
m[nRow][nCol] = fValue;
}
}
double matrix::GetElement( int nRow, int nCol ) {
if( nRow >= 0 && nRow <= nRows && nCol >= 0 && nCol <= nCols) {
return m[nRow][nCol];
} else {
return 0.0;
}
}
********************************************
Here is my code:
*************************
matrix m1( 3, 2 );
m1.SetElement (0, 0, 5.0);
m1.SetElement (0, 1, 4.0);
m1.SetElement (1, 0, 3.0);
m1.SetElement (1, 1, 2.0);
m1.SetElement (2, 0, 1.0);
m1.SetElement (2, 1, 0.0);
matrix m2( 2, 2 );
m2.SetElement (0, 0, 2.3);
m2.SetElement (0, 1, 3.7);
m2.SetElement (1, 0, 4.5);
m2.SetElement (1, 1, 6.9);
printf("Before multiplication ...\n");
matrix m3( 3, 2 );
m3 = m1 * m2;
printf("After multiplication ...\n");
printf("Element: %12.10f ", m3.GetElement (0, 0));
***********************
I marked the place where it fails above. I can't figure out why. Please help!!
Many thanks
|
|
|
|
|
Hi Anton,
Your class lacks a suitable copy constructor. The problem lies here:
m3 = m1 * m2; The expression m1 * m2 invokes matrix::operator * , which correctly builds the resulting matrix and returns it. But what m3 is being assigned is not that matrix, but a copy of it. As you haven't provided a copy constructor, the compiler uses the default one, which simply copies the object memberwise: so, the copied result member m really points to the same memory block as the matrix calculated in matrix::operator * ; by the time matrix::operator = enters into play, the internally calculated matrix has been destroyed, and the copied result points to non-valid memory.
More generally, when any function returns an object of whatever type, what the caller of the function gets is not the internal object, but rather a copy of it. The copy constructor is always implicitly called.
The morale is: copy constructors and assignment operators come in pairs, you cannot write one without writing the other. Keep this in mind and you'll save yourself a lot of trouble.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|