|
What update do you mean ?
If you mean how to update the data members, then I suggest you familiarize yourself with the concept of RFX, or Record Field Exchange . This practise is used to get data from the data source and save it into local variables (members of the CRecordset -derived object, such as CStrings , int s etc). When you issue a MoveNext call, the actual pointers inside the results list (handled by the CRecordset object) are moved forward. Then DoFieldExchange , an overriddable virtual function gets called. In here, if you issue a set of certain function calls (RFX calls), you can load the data in the currently selected row into the local variables you specify. We are not interested how the actual database or result browsing works: the CRecordset object offers an interface through which we can copy the desired data away into local variables.
The rest is quite simple: following the same logic, you implement a Dialog Data Exchange (DDX) routine, in which you copy the contents of the variables from the CRecordset object into local variables of the dialog class (member variable to member variable, respectively). After this, you let the DDX routine (DoDataExchange virtual function on the dialog class) to "bind" these local variables into the actual controls of the dialog resource. This means that whenever the DDX routine is ran, data is copied from either the local variables into the controls, or vice-versa.
The same bi-directionality is implemented in the CRecordset object, but it works a bit differently (See the CRecordset documentation for more info, especially AddNew and Update member functions).
Hope this clears it up a bit. See MSDN documentation for a complete explanation. Naturally, experimenting with both DDX and RFX is the best way to learn how to use them. But if you understand the basic concept: "Binding a local attribute of a class into a control's data/manipulation or into a query's result row's column", you've taken a huge leap forwards.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Oleg Galkin and Alexander Kuzmin give us solutions to this problem. Unfortunately, I cann't get it work well even in the easiest circumstances.
Is there any other good solution to it?
|
|
|
|
|
The easiest way, of course, would be to use a dynamic splitter instead.. But, if you want it to be static, you can always set the static frame's width/height to zero. This will 'hide' the window.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
CScrollview data plotting & grabbing the plotted data
>>
Mainly how to find what is the position of mouse pointer when clicked corresponding to data plotted
Hello friends
I am developing an application in which i have to
1.0 Get the data from file
2.0 Store it to array
3.0 Plot the data with MM_LOENGLISH mapping mode on view
(because i want printous as it is)
4.0 Allow user to grab the data from the view by clicking on the
selected portion from the view, say marquee select
5.0 Corresponding to user selection on view, grab the dat from
the array and then put the data into seperate file.
I am having query in point 4.0:
How can one implement the functionality in which the data has to be plotted on UI and certain part of data has to be grabbed from the visual display.
How the exact position of mouse is located on UI vis a vis data in array? (I want to grab the data on UI by selecting the data , there has to be a mapping with the array data?)
So that when i grab on UI i get some value on mouse clicking and then based on that i can grab the data?
No matter what ever the OS is i.e 2000 or Xp or 98.
No matter what ever the screen resolution is (It must work for all combination)
What i am doing presently is :
i am taking data from the document
Step 3.0 onwards
<br />
CPoint OldPointL, NewPointL;<br />
<br />
CSize sizeTotal;<br />
sizeTotal = GetTotalSize();<br />
long interval = (long)(((sizeTotal.cy * 0.95f) / 5)*0.9f);<br />
<br />
if(m_bFitToScale == true)<br />
{<br />
m_ScaleX = (float)ClientRect.Width () / <br />
(float)pDoc->m_ChannelDataArray.GetSize () ;<br />
}<br />
else<br />
{<br />
m_ScaleX = 1;<br />
}<br />
OldPointL.x = ClientRect.left;<br />
<br />
int Ly = OldPointL.y = (long)(ClientRect.top - ClientRect.Height () * 0.95f);<br />
m_GeoYScale = interval * 0.5f/ceilf(GetMaxValue());<br />
<br />
for(int xCount=0; xCount < pDoc->m_ChannelDataArray.GetSize (); xCount++)<br />
{<br />
NewPointL.x = (int)(m_LeftMargin + xCount * m_ScaleX) ;<br />
NewPointL.y = (int)( Ly + m_GeoYScale * data->GetLValue ()) ;<br />
CLine *pL = new CLine((float)OldPointL.x, (float)OldPointL.y,<br />
(float)NewPointL.x, (float)NewPointL.y, <br />
RGB(255, 0, 0), 1);<br />
pDoc->AddLine(pL);<br />
OldPointL = NewPointL;
}<br />
After this Invalidate is called and in ondraw i am drawing all the lines and labels ?
For step 4.0 i am going for onXButtonUp function
StartPoint = ScrollView.GetPosition() + point.x
(Point recd. from Onxbuttonup function)
Startpoint on left button and endpoint on R button
NOW MAIN TASK IS TO GRAB THE DATA FROM THE DATA ARRAY IN DOC BASED ON GRAB SELECTION ON VIEW
ANy help suggestion Please soon
I am not expert in this and i am learning, kindly can you give me sugestion?
I had posted the same theme query
http://www.codeguru.com/forum/showt...threadid=279607
Thanks
Leave your mark wherever you go
|
|
|
|
|
Hi all. Happy chinese new year. Do anyone know how to display simple text in a MDI application? Thank you.
|
|
|
|
|
In an MDI application, you first create the frame window. Then, you create child frames on request, and fill these frames with view windows. Each child frame owns one and only one view, unless there's a tab control inside the frame.
If you need to display text in a view, override the view's ON_WM_PAINT handler and use the TextOut function of the CDC class. This will draw text on your view.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I could be just a complete moron and not know where to look. But what I need help with is taking numbers from a edit box(when a button is clicked) and made into a varible. Then I want to take those variables and make another variable(I know how to do this), then I would like to output the product in a static field.(I think is simple but I don't know)
If someone could help me or point me in the right direction I'd greatly appreciate it.
Thanx
|
|
|
|
|
MrNiceBerG wrote:
then I would like to output the product in a static field
I'm not any MFC pro by any means, but I think this will do what you want.
(CStatic*)(GetDlgItem(ID_OF_STATIC))->SetWindowText(varWithProduct); That would be assuming that varWithProduct is some type of string. I'm sure there are other (probably better) ways to do it, but that might get you started.
- monrobot13
|
|
|
|
|
I am not really and MFC pro either, but perhaps I can grant more insight of what is happening to you.
If you are creating a dialog-based solution, you can use the Dialog Data Exchange to bind a CString object into the contents of the edit box. Then, calling UpdateData(TRUE) would copy the contents of the edit box into the CString variable. Calling UpdateData(FALSE) would update the controls from the variables.
After this, you can use the previously posted method to update the static control's text, issuing the name of CString object as a parameter to the SetWindowText method.
Here is a hands-on example on how it might be implemented:
CString m_csEditBoxText;
CStatic m_StaticControl;<DIV>
.... <DIV>
void CMyDialog::DoDataExchange( CDataExchange* pDX )
{
DDX_Text( pDX, IDC_EDIT_CONTROL_ID, m_csEditBoxText );
DDX_Control( pDX, IDC_STATIC_CONTROL_ID, m_StaticControl );
}<DIV>
.... <DIV>
void CMyDialog::OnClickButtonX( someParams )
{
UpdateData(TRUE);<DIV>
m_StaticControl->SetWindowText( m_csEditBoxText );<DIV>
UpdateData(FALSE);<DIV>
} This implementation should work, assuming you have given an identifier to both the edit box and the static control (all static controls default to having IDC_STATIC as their identifier). Then put these identifiers into the dialog data exchange routine. I have not tested it, but if it does not work, then use the implementation given in the previous post to update the static control's caption, removing the lowest two code lines from the button click handler.
Hope this will help you out
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanx Guys. I'm on my way out(I have some work I have to go take care of), when I get back I'll try it out and tell you how it comes out. Thanx again, I appreciate it.
One thing I'm having trouble with is getting the data(numbers) from an edit box and turning that into a float variable.(it's for a math equation). Thanx again.
|
|
|
|
|
I did have to change some things around but it worked well. I got the program to do almost everything I wanted it to do. I can't thank you enough for your help. It took me a while but once I figured things out I felt like a compelete idiot. If you just happen to be curios about how I did it and what I changed just email me and put C++ in SBJ line other wise I will probably delete it.
|
|
|
|
|
Hi
I want to create a tab control in such a wany that when user drags the tab button it should display it as separate dialog box. Also if user drags a dialog box on to that, it should set as a tab button. Any idea how this can be done?
Regards
Neha
|
|
|
|
|
You must do it completely yourself.
You could see the MFC source code of the CWnd class for the basic window functionality. For the docking stuff, always when your window is moved near enough to the docking area, the drag rectangle is forced to a certain place/size and is not moved with the mouse until the cursor is enough far away from the 'zone'.
For the tab controls, whenever the window is in the zone, you create a new rectangle that looks like a tab. Then you place this 'outlined' tab control next to the existing ones. If user releases the mouse button while in this mode, a new tab page gets created.
Basically, what you are asking has not been implemented yet, so there is little ready source code available. You must gather bits and pieces, experiment and succeed through trial & error.
Best of luck, though..
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi,
I was thinking to do the same.
Please, if you do any code for it, even not perfect, can you send it to me ( if yes I will give you my email address ) ?
If I will implement on my side I can give my code to you. Unfortuantely though, I am using the VCF library ( which makes this work much simpler than using MFC ), so I am not sure my code will fit your needs.
Cheers,
Marcello
|
|
|
|
|
I want to initialize a executable, making OS to search for the file. I am not able to resolve the error in 5th parameter.
STARTUPINFO si = {sizeof(si)};<br />
PROCESS_INFORMATION pi;<br />
TCHAR szCommandLine[1024] = {0},*pszCommandLine = 0;<br />
<br />
DWORD lFileName = <br />
SearchPathW(NULL,(LPCWSTR)"YPager",(LPCWSTR)".exe",(DWORD)sizeof(szCommandLine), szCommandLine, *pszCommandLine);<br />
<br />
BOOL bCreate = CreateProcessNULL,szCommandLine,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
The error is: 'SearchPathW' : cannot convert parameter 5 from 'char [1024]' to 'unsigned short *'.
Cheers!
Siddharth
|
|
|
|
|
Hello!
This is because you are calling Unicode version (SearchPathW). Use SearchPath or SearchPathA for non-Unicode version.
If parameter 5 is 'char [1024]' then TCHAR is defined as char, so _UNICODE is not defined.
Have a nice day or night
|
|
|
|
|
It's not working even with SearchPath(). There is no compiler error as such but the thing is not execeuting. Any other suggestion for solving the problem
|
|
|
|
|
Tell me exactly what you want to do. You want to locate executable file which is on system path? Or acquire path to executable which is currently running under the debugger?
|
|
|
|
|
I want to loacte executable where ever it is on the Harddisk. Thing is I am not sure whether exe will be in System Directory or Program Files.
Hence Search for the file on My Computer kind of thing.
Waiting for reply.
Cheers!!!
Siddharth
|
|
|
|
|
So you should not use SearchPath()
Use either SHFindFiles or locate the file by yourself, by traversing directories, and using FindFirstFile, FindNextFile.
Search path searches for file in:
1) The directory from which the application loaded.
2) The current directory.
3) The system directory. Use the GetSystemDirectory function to get the path of this directory.
4) The 16-bit system directory. There is no function that retrieves the path of this directory, but it is searched.
5) The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
6) The directories that are listed in the PATH environment variable.
These are not all directories for sure
|
|
|
|
|
That's very nice of you. These are very valuable suggestions. But do U agree with my thinking? Or can U suggest something better then that.
|
|
|
|
|
Hi all,
this is one of my first posts here. Hello.
I am into photography, and i want to write maybe an MFC application or something that does the following:
-take in a directory
-for each jpg in this directory, add a watermark to it
by watermark I mean a signature that shows that picture is mine.
do you guys know if this is possible?
thanks!
|
|
|
|
|
download cximage from here
add 3 (maybe 4) lines of code
voila
"there is no spoon" biz stuff about me
|
|
|
|
|
Hi,
I need to write a small program that backs up a Microsoft Access database in a specific way, and wondered if anybody here could offer me a little help.
Basically, this is what the program needs to do:
1) Copy the original database (.mdb file) to a different folder (the backup folder).
2) Change the database password of the backed up version (the backup needs a different password).
3) Set the properties of the backed up password to "Read-only".
1) and 3) are easy, but 2) is giving me problems. At the moment I have to do this manually at the end of each day - by opening the copy using "Exclusive access", unsetting and then resetting the database password. Essentially I just want to write a program to automate this process and save me time at the end of each day.
I am hoping that there is some way to automate step 2. If this is a really basic question, please accept my apologies. I have written a few basic C/C++ and WinAPI programs, but I have never interfaced with Access from another program.
Many thanks for any help or pointers,
KB
|
|
|
|
|
You might try posing question #2 to the folks in the Access section at http://www.mvps.org/[^].
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|