|
I am useing VC++ 2008 Service Pack2 OS Microsoft Windows XP.I had create simple Dialog Based application and add a button and Edit box.On Button Click open a folder dialog Box.When i click on Button and select a file name and again click on button then i am getting exception.
Unhandled exception at 0x7ca51646 in test.exe: 0xC0000005: Access violation reading location 0x01064db0.
I debug the code and found when cursor come here then exception
if (dlg.DoModal()==IDOK)
code of ButtonClick
const char szFilters[]="Excel Files|*.xls;*.xlsx|";
CKSFileDialog dlg (TRUE, "xlsx", NULL,OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters,this);
dlg.SetMyParent(this);
if (dlg.DoModal()==IDOK)
{
SetDlgItemText(IDC_EDIT1, dlg.GetPathName());
}
Plz help me
|
|
|
|
|
The end of the filter must have 2 pipe symbols.
const char szFilters[]="Excel Files|*.xls;*.xlsx||";
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
thank for reply but still problem is same.
|
|
|
|
|
Please try without the SetMyParent call.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
i try this but still problem is same.
|
|
|
|
|
Did you override DoModal in your class?
If so, what changes has been done in it.
Generally, what was the reason to derive your own class from CFileDialog ?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
derive your own class from CFileDialog
i was try this.But in that case also same exception show.
|
|
|
|
|
I'm trying to understand what your class CKSFileDialog does.
Why don't you directly use the CFileDialog class like this -
const char szFilters[]="Excel Files|*.xls;*.xlsx||";
CFileDialog dlg (TRUE, "xlsx", NULL,OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters,this);
if (dlg.DoModal()==IDOK)
{
SetDlgItemText(IDC_EDIT1, dlg.GetPathName());
}
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
i test code given by you but still exception is same.
|
|
|
|
|
|
|
At one time this was a known problem with CFileDialog . I would have thought it to be fixed by VS2008. It has to do with the size of the OPENFILENAME structure. This structure has three extra members if _WIN32_WINNT >= 0x0500. This causes problems because CFileDialog has a OPENFILENAME member, but MFC itself was built with the smaller size. Since the class in your app will not line up with what is in MFC, it crashes. See the first Q&A here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
thanks for article.
You have any solution for that problem.
|
|
|
|
|
MsmVc wrote: thanks for article.
Which I just realized was close but not the exact one I meant to post. Sorry about that.
MsmVc wrote: You have any solution for that problem.
Did you see the CFileDialogEx class? Have you considered using GetOpenFileName directly?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
yes i try
CFileDialogEx but nothing change in output.Still i am getting exception.
|
|
|
|
|
I am using automation classes to draw chart through excel from VC
Is there any documetation where i can get the values of the variables to passed to ChartType
Ex I have this code
_Application app;
_Workbook newBook;
Workbooks books;
Worksheets sheets;
_Worksheet newSheet;
Charts charts;
_Chart newChart;
COleVariant vOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
//Create Excel server (start Excel)
if(!app.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Can’t start Excel server!");
return;
}
app.SetVisible(true); //set Excel visible
// app.p.put_UserControl(TRUE); //user can operate Excel
books = app.GetWorkbooks();
newBook=books.Open("d:\\wipro1.csv",vOpt, vOpt, vOpt, vOpt, vOpt,
vOpt, vOpt, vOpt, vOpt, vOpt,vOpt, vOpt,vOpt,vOpt);
sheets = newBook.GetSheets();
newSheet = sheets.GetItem(COleVariant((short)2));
charts = newBook.GetCharts();
newChart = charts.Add(vOpt,vOpt,COleVariant((short)1));
newChart.SetName("My chart");
newChart.SetChartType((long)1);
---------------------------
The above code works fine but what variables should be passed to SetChartType ? which Variable corresponds to which charttype?
Prithaa
|
|
|
|
|
good morning
Here are the value for excel 12 ?
well the values retrieved from Microsoft.Office.Interop.Excel.dll
runtime version v1.1.4322
version 12.0.0.0
public enum XlChartType
{
xlXYScatter = -4169,
xlRadar = -4151,
xlDoughnut = -4120,
xl3DPie = -4102,
xl3DLine = -4101,
xl3DColumn = -4100,
xl3DArea = -4098,
xlArea = 1,
xlLine = 4,
xlPie = 5,
xlBubble = 15,
xlColumnClustered = 51,
xlColumnStacked = 52,
xlColumnStacked100 = 53,
xl3DColumnClustered = 54,
xl3DColumnStacked = 55,
xl3DColumnStacked100 = 56,
xlBarClustered = 57,
xlBarStacked = 58,
xlBarStacked100 = 59,
xl3DBarClustered = 60,
xl3DBarStacked = 61,
xl3DBarStacked100 = 62,
xlLineStacked = 63,
xlLineStacked100 = 64,
xlLineMarkers = 65,
xlLineMarkersStacked = 66,
xlLineMarkersStacked100 = 67,
xlPieOfPie = 68,
xlPieExploded = 69,
xl3DPieExploded = 70,
xlBarOfPie = 71,
xlXYScatterSmooth = 72,
xlXYScatterSmoothNoMarkers = 73,
xlXYScatterLines = 74,
xlXYScatterLinesNoMarkers = 75,
xlAreaStacked = 76,
xlAreaStacked100 = 77,
xl3DAreaStacked = 78,
xl3DAreaStacked100 = 79,
xlDoughnutExploded = 80,
xlRadarMarkers = 81,
xlRadarFilled = 82,
xlSurface = 83,
xlSurfaceWireframe = 84,
xlSurfaceTopView = 85,
xlSurfaceTopViewWireframe = 86,
xlBubble3DEffect = 87,
xlStockHLC = 88,
xlStockOHLC = 89,
xlStockVHLC = 90,
xlStockVOHLC = 91,
xlCylinderColClustered = 92,
xlCylinderColStacked = 93,
xlCylinderColStacked100 = 94,
xlCylinderBarClustered = 95,
xlCylinderBarStacked = 96,
xlCylinderBarStacked100 = 97,
xlCylinderCol = 98,
xlConeColClustered = 99,
xlConeColStacked = 100,
xlConeColStacked100 = 101,
xlConeBarClustered = 102,
xlConeBarStacked = 103,
xlConeBarStacked100 = 104,
xlConeCol = 105,
xlPyramidColClustered = 106,
xlPyramidColStacked = 107,
xlPyramidColStacked100 = 108,
xlPyramidBarClustered = 109,
xlPyramidBarStacked = 110,
xlPyramidBarStacked100 = 111,
xlPyramidCol = 112,
}
Regards
Franck
|
|
|
|
|
Hello,
I have used the above chart types and to draw stock volume option
xlStockVOHLC = 91 . The data is arranged properly in excel sheet but how to select data for the chart in columns
i m using the following for data range
_Chart newChart;
Range oRang;
oRang = newSheet.GetUsedRange()
newChart.SetSourceData(oRang,COleVariant((short)1));
pritha
|
|
|
|
|
Hi,
I am trying to automate the opening file in framemaker and then try to convert it into xml file. While opening the file in framemaker i get some dialogs with OK and Cancel button.
For some file these dialogs come up but not for others.
How do i handle these dialogs in my code.
Thanks in advance for any help
|
|
|
|
|
I know that we can launch the Playback tab of the Sound control panel with the command:
rundll32 shell32.dll,Control_RunDLL mmsys.cpl,,0
But if I need to launch the Speaker Properties dialog box programmatically, how can we do that? Do we need to post some Windows message to some process?
Note: Speaker Properties can be found by mouse-clicks via right-clicking the "Speakers" entry on the list control on the "Playback" tab of Sound panel.
Maxwell Chen
|
|
|
|
|
This article[^] seems to be a nice solution to me. Let me try ...
Maxwell Chen
|
|
|
|
|
|
Hello
Does memory mapped file I/O has a real advantage over disk I/O. Because I am trying to read a file using ::ReadFile API (block by block) and compare it with memory mapped file I/O mechanism from http://www.codeproject.com/KB/files/mmfio.aspx I then tried to compare the time taken to read a file of 700MB using both the techniques. I found that the memory mapped file I/O took almost the same time as disk I/O or sometimes more time.
So, would like to know whether memory mapped file I/O does really provide an advantage over disk I/O and how do I achieve it.
Thanks
|
|
|
|
|
When reading the complete contents of a file, possibly not. However, with a big file, if you only want to read separate parts of the file, memory mapping gives you the convenience of memory-style accesses, and will only read the pages of the file you touch (whatever the page size of the VM system is). Consider if you wanted to read the first and last bytes of that file - you could map the whole file, read the first byte and the last byte and the disk IO system would have read two pages (2 x 4kB?). And you read those bytes through pointers.
Another advantage - memory mapped IO sections can be defined using pointers (pointer to start, pointer to end), which are random-access iterators as far as the STL is concerned. File iterators in STL are forward-only iterators.
I generally prefer to use memory-mapping when possible, as it's (IMO) easier to manage and use, mainly because of the STL related iterator thing.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,all
I have a windows service program with a service,and I can use "myservice/service" in cmd.exe,it sucess!
then,I can see the service in control pane,I also can start up this service;
But, this service can't run my code; why??
the whole code here
void yourfunction()
{
for (int a =0; a<10; a++)
::MessageBoxA(NULL, "ggg", "ghgh" ,MB_OK);
}
SERVICE_STATUS ServiceStatus =
{
SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
SERVICE_STOPPED,
SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_PAUSE_CONTINUE,
0,0,0,0
};
TCHAR szSvName[]=TEXT("Myservice1");
SERVICE_STATUS_HANDLE hStatus;
SC_HANDLE SCMger;
void WINAPI ControlHandler(DWORD request);
void ServiceMain(int argc, char* argv);
void CreateMyService()
{
SCMger=OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
CreateService(
SCMger,
szSvName,
szSvName,
SERVICE_START,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_IGNORE,
TEXT("c:\\myservice1.exe"),
NULL,
NULL,
NULL,
NULL,
NULL);
}
int main()
{
SERVICE_TABLE_ENTRY ServiceTable[2];
ServiceTable[0].lpServiceName = szSvName;
ServiceTable[0].lpServiceProc=(LPSERVICE_MAIN_FUNCTION)ServiceMain;
ServiceTable[1].lpServiceName = NULL;
ServiceTable[1].lpServiceProc= NULL;
if(StartServiceCtrlDispatcher(ServiceTable)==0)CreateMyService();
}
//this fun also can't be debug,can't run
void ServiceMain(int argc, char* argv)
{
hStatus = RegisterServiceCtrlHandler(szSvName,ControlHandler);
ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_SHUTDOWN;
SetServiceStatus(hStatus,&ServiceStatus);
ServiceStatus.dwWin32ExitCode = NO_ERROR;
ServiceStatus.dwCheckPoint = 0;
serviceStatus.dwWaitHint = 0;
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
SetServiceStatus(hStatus,&ServiceStatus);
yourfunction();
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus(hStatus,&ServiceStatus);
}
//this fun can't be debug,can't run
void WINAPI ControlHandler(DWORD request)
{
switch(request)
{
case SERVICE_CONTROL_SHUTDOWN:
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus(hStatus,&ServiceStatus);
break;
}
}
|
|
|
|
|