as i understand LockResource returns a pointer to the first byte of the data stored in the resource.. currently i use fstream to read, validate and store some wave file data so that it can be used to play back the wave file since the open function of fstream takes a char* for the name of the file to open, i wondered if a char* for the resource would work in the same way i think my confusion is as you say with fstream but since the class i want to use the data from the resource with is based on fstream, i wondered if there was a solution that doesnt involve re-writing the class..
bimgot
Posts
-
using fstream to read resource data c++ -
using fstream to read resource data c++my application currently reads and uses data from files at a location on the host machine using fstream what i would like to do is include these files and their data as resources so that the application does not rely on the data being stored on the host machine i am using FindResource, LoadResource, LockResource etc but i'm having trouble passing the actual data content straight to fstream - is this possible??
FindResource(..); LoadResource(..); char* ptr = (char*) LockResource(..); fstream.open(ptr,ofstream::binary);
any help would be greatly appreciated - i'm pretty new to resources! -
accessing parent variables from dialog mfc??sorry i was unclear here, i need to control the window in that i want to be able to update its variables, but i dont need to physically control or move the window..
-
accessing parent variables from dialog mfc??i dont believe it is no.. if i call void CformView::OnViewDlg() { CDlg dialog; dialog.dlg_level = form_sldr.GetPos(); dialog.DoModal(); form_sldr.SetPos(dialog.dlg_level); } this updates the variable when the dialog is closed, but i want to update the variable as the dialog is running.. trying the same but with: form_sldr.SetPos(form_level); after DoModal(); doesnt update the control in the same way..
-
accessing parent variables from dialog mfc??void CDlg::OnTimer(UINT_PTR nIDEvent) { CDialog::OnTimer(nIDEvent); dlg_level = dlg_sldr.GetPos(); CformView* form = (CformView*) GetParent(); // form points to the main form class correctly form->form_level = dlg_level; form->UpdateData(TRUE); UpdateData(TRUE); } void CformView::OnViewDlg() { CDlg dialog; // this points to the main form class as this is a member function dialog.dlg_level = form_sldr.GetPos(); dialog.DoModal(); } i did consider a modal dialog as bieng inappropriate for this but was unsure as i dont actually need to control the main window whilst the dialog is open, i just want to update some variables..
-
accessing parent variables from dialog mfc??thanks very much, i understand UpdateData a bit more now, i think i must have initialised something incorrectly, this still doesnt seem to update the values in the form.. the pointer to the main form is working correctly, if i call something like form->CloseWindow() during OnTimer it works.. i'm using OnTimer() in the main form to actually call the function which sets the volume: void CformView::OnTimer(UINT_PTR nIDEvent) { CFormView::OnTimer(nIDEvent); SetVolume(form_level); UpdateData(FALSE); } would this still get called during the life of the dialog or do i need to set the volume somewhere else? also is it possible some of the properties of the dialog could be effecting things?? really racking my brain here.. thanks
-
accessing parent variables from dialog mfc??OnTimer in the dialog class: void CDlg::OnTimer(UINT_PTR nIDEvent) { CDialog::OnTimer(nIDEvent); dlg_level = dlg_sldr.GetPos(); CformView* form = (CformView*) GetParent(); form->form_level = dlg_level; form->UpdateData(TRUE); UpdateData(TRUE); } then from form view class: void CformView::OnViewDlg() { CDlg dialog; dialog.dlg_level = form_sldr.GetPos(); dialog.DoModal(); } hope this makes sense
-
accessing parent variables from dialog mfc??have tried UpdateData() does the dialog class require any settings in order to access the parent variables? i've even tried just very simple variable tests in OnTimer in the dialog class and it seems to have no effect on them.. is OnTimer even the right function to be using? i use it in the main form for a simelar process so i figured it would be but perhaps its different for dialogs?
-
accessing parent variables from dialog mfc??i'm quite new to mfc/c++ and i'm trying to create a really simple dialog box which controls the master volume of a simple form view application.. i've created the dialog and the variables to control the master volume in the form class (i've tested by creating a control in the form view and this works fine) but when i try to access and alter the form parameter from the dialog using a pointer and GetParent() during OnTimer(), it just does nothing... am i missing something? thanks in advance
-
Accessing CView from CDialog MFC???thanks very much, fairly new to MFC so sorry if that was a bit obvious!
-
Accessing CView from CDialog MFC???thanks alot this looks like it will work for me, however i've just had a quick look and when i try to set the position of the dialog slider from the view code (ie "dlg.m_nSlider.SetPos(0)) i get an assertion failure with "afxcmn.inl" which breaks at the SetPos function.. have i missed something? in the dialog code i've set up a member variable linked to the dialog slider with DoDataExchange and i've also used OnInitDialog() to set the range of the slider.. but other than that i think its as above.. thanks in advance
-
Accessing CView from CDialog MFC???hi there, i'm building a SDI form application and thought it might be good to have a dialog box as a set of alternate controls for a few parameters of that application.. is this possible? i've created the dialog box resource but i'm having some trouble getting them to talk to one another.. for example - the main form contains a few slider controls for parameters and this all works fine, but i also want to be able to control these parameters from a seperate dialog box, and ideally i'd want them to correspond on submission (if moved in the dialog box, the original is updated..) is there any way to link 2 controls to 1 parameter? should i be working with a MDI? thanks in advance!