|
I am creating a DialogBar, however I have to assosiate the DialogBar resource with the View Class because it needs to be able to access data members from the view. however now I have a problem.. I need to be able to figure out how to retrive the m_wndDlgBar data member from the frame. so I can add code in my view as such
CSliderCtrl* pSlide = (CSliderCtrl*)m_wndDlgBar.GetDlgItem(IDC_DIALOG_BAR);
any help would be appreciated
|
|
|
|
|
There are several solutions. One solution is to class a function in view. Another solution is messages.
Kuphryn
|
|
|
|
|
Can you give a little more detail on either method.
I tried creating a public function in CMainFrame such as
CToolBar& GetToolBar(){return m_wndToolBar;}
then tried to access CMainFrame::GetToolBar()
but of course that didn't work..
|
|
|
|
|
One solution to accessing main frame is AfxGetMainWnd().
Kuphryn
|
|
|
|
|
I thought of that is well, but AfxGetMainWnd() does not give me access to the toolbars or statusbars.
|
|
|
|
|
I have Doc/View application.
Upon one user command I create thread passing some user-defined data to it.
This is the thread procedure:
UINT ThreadLocalCopy(LPVOID pParam)
{
___THREAD_COPY_PARAM* p_info = (THREAD_COPY_PARAM*)pParam;
___BYTE type = 0;
___DlgLocalCopy::LocalFolderCopy("", type, p_info);
___// finish operation
___::SendMessage(p_info->h_wnd, WM_THREADFINISHED, 0, 0);
___return 0;
}
And here's DlgLocalCopy::LocalFolderCopy() funcion, which is called from the thread above:
void DlgLocalCopy::LocalFolderCopy(LPCTSTR pth, BYTE &type, THREAD_COPY_PARAM *p_param)
{
___DlgOverwrite1 dov;
___DlgGetText dgt;
___DlgExpandSelection ds;
___CFileFind fff;
___CMainFrame* mf = (CMainFrame*) AfxGetApp()->GetMainWnd();
___CMyDoc* p_doc = (CMyDoc*) mf->GetActiveDocument();
___.
___.
___.
}
But calling CMyDoc* p_doc = (CMyDoc*) mf->GetActiveDocument()
fails in CWnd::AssertValid()
on this line:
ASSERT((CWnd*)p == this); // must be us
Why? I think that the stuff I am doing here is thread-safe, isn't it? I am not passing any CWnd objects to thread, I just call
AfxGetApp()->GetMainWnd()->GetActiveDocument()
inside the thread and it is not forbidden, is it?
Or if it is, how to achieve it another (safe) way?
Any help would be gratefully appreciated.
Standa.
|
|
|
|
|
MFC's handle maps are maintained on a per thread basis, so from your worker thread AfxGetApp()->GetMainWnd() won't work. One solution is to pass CMyDoc* to your thread creation function. Also it isn't a good idea to use SendMessage() from a thread, use PostMessage() instead or Events. Have a read of the Threading articles here on CP.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Hello
I need a view class that can show formatted text with pictures, tables and font colors in two columns (MSWord-like with text flowing from one column to another) with page divisions.
It can be read-only, but with copy operation support.
I was adviced that I can use PDF format in some way.
Can anyone help me with at least a starting point to look for info - some MFC classes, custom controls or articles and sites in inet?
Thank you in advance
|
|
|
|
|
Trying to retrieve CPU temperature, HDD temperature, information in my application. Does there exists some sort of BIOS wrapper class? Can anyone help me?
|
|
|
|
|
Hiya am getting a syntax error on using CREATE TABLE in SQL and an Access database:
// open the database
database.Open( NULL,false,false,sDsn );
database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName TEXT(10) ) ");
Does anyone know what is wrong with the ExecuteSQL line..
Thanks
grahamoj.
|
|
|
|
|
Hiya again, I found out my problem. Missing comma i.e
database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4),OfficeName TEXT(10) ) ");
So now what I need to be able to do is make the text field 600 chars. So tried these:
database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName TEXT(600) ) ");
and
database.ExecuteSQL("CREATE TABLE OFFICES (OfficeID TEXT(4) OfficeName MEMO(600) ) ");
but it won't create the table because text fields are too long..
any ideas on how to do this??
grahamoj.
|
|
|
|
|
I have an SDI application, in which my CView inherits from CScrollView.
I display a bitmap on the view window (576X768). I redraw this bitmap every 1 second.
The problem is: when I move the scroll bar, the redraw of the bitmap resets the scroll position. What message I need to catch, or what function I can overload in order to handle this problem?
|
|
|
|
|
Your code that draws the bitmap needs to take into account the current scroll position when displaying the bitmap:
int x = GetScrollPos(SB_HORX);
int y = GetScrollPos(SB_VERT);
If you treat these values as -ve destination plot position when drawing the bitmap, it should show correctly.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
I am prompted with what type of project I want to start, I pick MFC because I want to work with forms. But being a newbie, it took me 3 days to figure that out!
I still dont know what MFC stand for, or why I have to choose it to use forms. How does this differ from Application? I assume that I can still use forms in Application mode, I just have to go through the process of creating them?
Can anyone educate me, or point me to a dummie's link that would explain this?
Thanks,
Andrew
=================================
New to VC++ programming, working hard to learn.
Programming platform: eVC++ 3.0 for WinCE/PPC
=================================
|
|
|
|
|
MFC stands for Microsoft Foundation Class. I don't know enough about the different types of projects to try to explain them, but there are many excellent articles on CP that explain a lot of this stuff. Nothing will beat a good intro book on VC++ though. Hope you get it all figured out.
Brad Jennings
"if the golden arches shut shop, where else are the VB people going to get work." - Colin Davies
|
|
|
|
|
Ive got Microsoft Press:
Visual C++ .NET Step by Step
Its pretty good, but Im not digesting it all.
Ive also got two older books, some of the stuff applies, much of it doesnt:
Sams: Moving from QBasic to C
Sams: Absolute Beginner's Guide to C (2ed Ed.)
Dont know yet, if the books help, or hinder...
Andrew
=================================
New to VC++ programming, working hard to learn.
Programming platform: eVC++ 3.0 for WinCE/PPC
=================================
|
|
|
|
|
If you are looking for some C and C++ material, here[^] is a great website. This is the class website for the Intro to C++ class I took a few years ago. His reference note and lecture notes are excellent IMO and I still use them from time to time.
Brad Jennings
"if the golden arches shut shop, where else are the VB people going to get work." - Colin Davies
|
|
|
|
|
Hello,
I can not use CAtlMap when the template parameter is CString or other similar user-defined type in a MFC project, like CAtlMap<CString,CString>. Every time I get the C2440 error(cannot convert from 'type1' to 'type2'). And I found the "afx.h" caused the error.
Has someone met this problem? I must use ATL collection classes in MFC project, How can I do?
Thanks.
Kerry Chou
|
|
|
|
|
hello experts,
is there any method for manipulating SYSTEMTIME ? I want to be able to add hours/seconds/minutes/days/month/year to a SYSTEMTIME. just wondering if there are some prewritten apis for this purpose?
thanks
|
|
|
|
|
|
Okay, Ive got the other part of my problem fixed, and it appears to be working... That is, fetching text values from Edit Boxes and converting them to Long, then adding them for the sum.
Now, I want to convert the sum variable back to text so it can be used in a message box.
Heres what I have, code snippit:
===========================================================
// Fetch the text from Edit Boxes 1 and 2, and assign them
// to variables Number1 and 2.
GetDlgItemText(IDC_EDIT1, Number1);
GetDlgItemText(IDC_EDIT2, Number2);
// Initilize Long variables for number 1 and 2,
// and the resulting sum, Answer.
long N1;
long N2;
long Ans;
// Convert the text Number1 to Long N1,
// and 2 respectivly
N1 = wcstol(Number1, NULL, 10);
N2 = wcstol(Number2, NULL, 10);
// Add for the sum
Ans = N1 + N2;
// * Error compiling here.. *
// Objective: convert the Long Ans to the
// string AnsSum for printing in message box, etc..
CString AnsSum = atol( Ans );
// Build the text string TmpTxt to be used in message box
CString TmpTxt = "The numbers are " + Number1 + " and " + Number2 + " and the sum is " + _T(AnsSum);
// Finally, display the message box
MessageBox(TmpTxt, _T("Your answer"), MB_ICONINFORMATION | MB_OK);
===========================================================
Im getting these errors:
error C2664: 'atol' : cannot convert parameter 1 from 'long' to 'const char *'
error C2065: 'LAnsSum' : undeclared identifier
error C2666: '+' : 5 overloads have similar conversions
As you may recall from my previou post, this is a super newbie project Im working on, fetch two text vals from two edit boxes, convert them to Long, add them for the sum, convert the Long sum to Text and display the answer in a message box.
This project is introducing me to several various 'C++' structures and getting me used to the IDE. I am making progress, but I feel like a total idiot because I cant develop this simple app without having to ask questions.
I come from years of app dev with VB, so this is quite a change for me.
If you reply, please address me as the idiot I am so I understand what I am doing wrong, and what I need to do, and if you feel fancy, the why...
Thanks,
Andrew
New to VC++ programming, working hard to learn.
|
|
|
|
|
atol() converts an ANSI string to long integer. The function you want is _itoa() (ANSI) or _itow() (UNICODE) or _itot (ANSI and UNICODE) which converts a long integer to a string.
From your previous post I am lead to believe you are using a UNICODE enviroment, so you should either use UNICODE functions (have a 'w' in them instead of an 'a') or use the TCHAR macros.
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!
|
|
|
|
|
Same problem as before, you're using an ANSI function (atol ) and passing it a Unicode string (CString has a converter to LPCWSTR ). Check out The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^] -- it explains the different string types and functions. You absolutely need to know this for Win32 programming. Just remember that in WinCE, everything is Unicode.
--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
|
|
|
|
|
The link to strings has some great information in it, i think, Im too stupid at this point to understand most of what Im reading... Give me some time, Ill figure it out. I had little or no help learning VB, so this is like deja-vu.
New to VC++ programming, working hard to learn.
|
|
|
|
|
PocketBlast wrote:
error C2065: 'LAnsSum' : undeclared identifier
Hey kewl , I was wondering where you had an Identifier named 'LAnsSum' until I saw that you wrapped 'AnsSum' in a _T() macro. The _T() macro is used to declare a literal string in your code as either an ANSI or UNICODE string. Basicly what it does is use the preprocessor to prepend a 'L' in front of what ever text you run through it.
#ifdef _UNICODE
#define _T(str) L##str
#else
#define _T(str) str
#endif
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!
|
|
|
|