|
Good luck ...
I've been trying to do this myself, and I can't really do it; there's a post in the archive section of the datamekanix ( see other answer ) that tells you to do something like :
void CMyBar::SetWidth(const int nWidth)
{
if (IsFloating())
m_szFloat.cx = nWidth;
else if (IsHorzDocked())
m_szHorz.cx = nWidth;
else
m_szVert.cx = nWidth;
m_pDockSite->DelayRecalcLayout();
}
but I was never able to make it work
|
|
|
|
|
hello everybody
I need some help with declering an pointer to my clss
my class of CFromView in there i have a function class LoadImages
<br />
class CTestView : public CFormView<br />
and i have a different class and object some where else and i want to point to this class where i double click my control
and load my images
<br />
CTestView *pView = (CTestView *)((CFormView *)AfxGetApp()->m_pMainWnd)->GetActiveWindow();<br />
I new at this MFC Visual C++ program
can any one please help me
thanks...........
|
|
|
|
|
I think it's AfxGetMainWnd()->GetActiveView(). you only need to cast to CTestView*.
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
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
|
CMainFrame * pMain = (CMainFrame*) AfxGetMainWnd();
pMain->GetActiveView();
Sorry, I abandoned MFC a long time ago.
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
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
It's ok thanks for trying
in my program the is no GetActiveView() i keep getting an error.
maybe i'm putting this in the wrong way
this is what i have
CTestView * pView= (CTestView*)AfxGetMainWnd();
and lets say i want to call and function or an object like
this
pView->m_cThumbFrame.Add("picture.bmp");
but this dosen't work ((
|
|
|
|
|
E3 wrote:
in my program the is no GetActiveView() i keep getting an error.
After the cast ? Compiles fine here.
E3 wrote:
CTestView * pView= (CTestView*)AfxGetMainWnd();
Won't work. You'll get the CMainFrame class, which when cast has a GetActiveView() method.
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
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
It would be better to store the view-pointer for each view in a own variable to ensure you getting the right view pointer.
If not you are to crush and not to know why.
(If you do´t do this than check with the CObject::IsKindOf or something that the pointer is a object type of the class)
Try this @ home. (B&B)
|
|
|
|
|
I find it easier to store a pointer to the CView derived class in my CWinApp derived class. This guarantees that I'm working on the correct view.
Assuming you are calling your function from your CFrameWnd derived class, you may be able to use GetActiveView and cast it to the CTestView.
I prefer the first method but then I tend to have a lot of CView classes in my projects.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
thank you all for helping me... I finaly got the some of a b.... to work hehehe
here is what i did to get it working for all those people who mite get stuck on this and are new like me.
<br />
<br />
CFrameWnd* pFrame=(CFrameWnd*)AfxGetMainWnd();<br />
CTestView *p = (CTestView *)pFrame->GetActiveView();<br />
p->LoadImages(str);<br />
<br />
<br />
and this get the current CFormView window and everything works.....
thanks all guys....for all your help ;)
E3
|
|
|
|
|
Gurus!
I am working on a Doc/View SDI Application, The view is FormView, it has a CPropertySheet which has two Property pages. Now in some scenarios when something in the document changes, i need to re-populate some controls in those property pages. I was thinking of posting some private messages in the Document and catch those messages in the Property pages, but couldn't work it out.
Could you send me some code snippet how to implement it and is this the right approach of doing it.
Please reply asap.
TIA
|
|
|
|
|
You can not send messages directly to property pages. You need the handler in the sheet.
Anyway, if your document changes and you want to notice the views(s) UpdateAllViews() is the way to go. You can send a private "magic number" with it as a Hint, and all Views of your document get this (Via OnUpdate() ).
The Views in turn hand any notification down to their children e.g. a CPropertySheet , or they query the property sheet for the active page and work with that.
With all this, be sure that you do NOT duplicate data that you have in the document! Have the pages show the documents data, not the document send its data to the pages for duplicate storage!
You get in all kinds of inconsistency troubles if you try (and inevitably fail) to do so.
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
Thanks jhwurmbach for your advise,
I actually need to pass a hint actually, on which propretypages need to reload them with the data.
Thanks again for the adivse.
|
|
|
|
|
Hi y'all! Can anyone tell me how to create an EditWordBreakProc function for Word Wrap
option in Win32 application ?
|
|
|
|
|
Hello,
I have 2 status bars in my SDI app.. The second status bar is only displayed when specific functions are ran and it's displayed right above the standard status bar at the bottom.. is there a way I can take the gripper off of the top status bar.. it looks really bad having 2 grippers.. I have tried to ~SBARS_SIZEGRIP on the bar style but it doesn't work.
Any ideas?
Rob
|
|
|
|
|
You have to derive a new class and set the ~SBARS_SIZEGRIP in its precreatewindow().
Search MSDN and you will find it. It is a bug.
Hari Krishnan
|
|
|
|
|
0 errors, 0 warnings.
why?! why?! why!! ! ! !
anyone want to get email and try to help me solve this?? I got an evil mysterious bug.
Ive tried 3 seperate file handling libraries , I dont even think its a file handling problem anymore. compiles and links fine, but its getting a microsoft send / dont send error dialog and crashing.
argh!!!
|
|
|
|
|
jDawwg wrote:
0 errors, 0 warnings.
This says that there are NO compilation and link errors or warnings, it does not say that your application is without bugs and defects!
Can you tell us more ? What you are doing, where it crashes ( have you run it in a debugger ? started with the F5 key )
Max.
|
|
|
|
|
jDawwg wrote:
0 errors, 0 warnings.
why?! why?! why!! ! ! !
Your code has no syntax errors.
Why it crashes is impossible to tell when you don't post the your code that crashes!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
sorry
heres the code
......
int len;
int result;
char c2[255];
char c3[]="\0";
char c4[]="";
<br>
AfxMessageBox("Starting The Bouncer!");
<br>
HENV hEnv = NULL;
HDBC hDBC = NULL;
HSTMT hStmt = NULL;
UCHAR szDSN[SQL_MAX_DSN_LENGTH] = "cplusmysql";
UCHAR szUID[10] = "xxxx";
UCHAR szPasswd[10] = "xxxx";
UCHAR szModel[128];
SDWORD cbModel;
RETCODE retcode;
<br>
SQLAllocEnv (&hEnv);
SQLAllocConnect (hEnv, &hDBC);
<br>
retcode = SQLConnect (hDBC, szDSN, SQL_NTS, szUID, SQL_NTS, szPasswd, SQL_NTS);
<br><br>
BOOL freeResult, runTimeLinkSuccess = FALSE;
HINSTANCE dllHandle = NULL;
BounceCheckType BounceCheckPtr = NULL;
dllHandle = LoadLibrary("bBounce.dll");
<br>
BounceCheckPtr = (BounceCheckType)GetProcAddress(dllHandle,"BBBOUNCECHECK");
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
CFileInfoArray fia;
fia.AddDir(
m_spoolpath,
"*.*",
TRUE,
CFileInfoArray::AP_SORTBYNAME | CFileInfoArray::AP_SORTASCENDING,
FALSE
);
for (int ji=0;ji<fia.GetSize();ji++) {
ifstream is;
is.open (fia[ji].GetFilePath(), ios::binary );
is.seekg (0, ios::end);
int length = is.tellg();
is.seekg (0, ios::beg);
char * c1 = new char [length+1];
is.read (c1,length);
is.close();
c1[length+1] = '\0';
if(NULL != dllHandle)
{
if (runTimeLinkSuccess = (NULL != BounceCheckPtr))
{
result = BounceCheckPtr(*c1, *c2, len, *c3, *c4);
}
}
UCHAR szSqlStr[128];
if (result == 1) {
sprintf((char*)szSqlStr,"INSERT into bouncetest Values ('HB', '%s')",c2);
SQLAllocStmt (hDBC, &hStmt);
SQLPrepare (hStmt, szSqlStr, sizeof (szSqlStr));
SQLExecute (hStmt);
SQLBindCol (hStmt, 1, SQL_C_CHAR, szModel, sizeof(szModel), &cbModel);
SQLFetch (hStmt);
SQLFreeStmt (hStmt, SQL_DROP);
}
delete[] c1;
}
freeResult = FreeLibrary(dllHandle);
}
SQLDisconnect (hDBC);
SQLFreeConnect (hDBC);
SQLFreeEnv (hEnv);
AfxMessageBox("Finished Sorting Bounces");
|
|
|
|
|
...
char * c1 = new char [length+1];
is.read (c1,length);
is.close();
c1[length+1] = '\0';
... The last line should be
c1[length] = '\0'; This is the first thing I've noticed on a quick review, maybe some more errors are still lurking in the code.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
changed that to what you suggested, still crashes.
|
|
|
|
|
If you could put a breakpoint in at the start of the function, and then Step through the code to find out where the program bombs it would be a lot of help for us to be able to find the bug.
|
|
|
|
|
did that,
it dies at
delete[] c1;
also, i will send anyone who needs a better look the project files if you need them.
|
|
|
|
|
sprintf((char*)szSqlStr,"INSERT into bouncetest Values ('HB', '%s')",c2); c2 is not initialized to anything, this is faulty. Moreover, szSqlStr is not given space enough to accomodate the maximum string possible, approx. equal to 255 plus some 50 chars.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|