|
Its because AfxMessageBox creates a model dialog box, which is supposed to prevent interaction with application. I you want to be able to interact with application while a dialog is being showed look for modeless dialog in msdn.
-Saurabh
|
|
|
|
|
Oh but the message box does not even show up! Or could it be that I just can't see it, but don't think so. I tried the message box in another dialg application (which is a lot simpler though) and it works fine there. Very strange!!
|
|
|
|
|
are you sure line containing AfxMessageBox is being executed. can you try to put a breakpoint at that line, run in debugging mode, and see if control reaches that line.
-Saurabh
|
|
|
|
|
hi,
please help me, how to access picture in memory
i have try used DirectShow but stiil can't
|
|
|
|
|
Can you be more explicit? what's the source of picture, what format is it in.
-Saurabh
|
|
|
|
|
Hello,
I wrote one post this day to my problem. Now I am able to describe my problem more detailed. So once more:
I want to write a base class and a class that manage a list of objects derived from my base class. The list-class should have a = operator that copies the whole list and creates copies of all its elements (derived from base class).
The base class is derived from CObject because of serialisation and so on. It also includes some basic methods and members.
<br />
class CBase::Cobject<br />
{<br />
....<br />
}<br />
Now I derive some classes from it.
<br />
class CA::CBase<br />
{<br />
}<br />
<br />
class CB::CBase<br />
{<br />
}<br />
<br />
All classes should have a = operator to copy its elements!
The list-class now have a list of pointers to some instances from CA und CB in a CObArray.
The = operator of the list-class shoud create a copy of the list an the members.
<br />
CBase* pElement1;<br />
CBase* pElement2;<br />
CRuntimClass* pRTC;<br />
int nIndex;<br />
<br />
for (nIndex=0; nIndex<pList->GetCount(); nIndex++)<br />
{<br />
pElement1 = pList->GetAt(nIndex);<br />
pRTC = pElement1->GetRuntimeClass();<br />
pElement2 = (CBase*)pRTC->CreateObject();<br />
pRTC = pElement2->GetRuntimeClass();<br />
*pElement2 = *pElement1;<br />
Add(pElement2);<br />
}<br />
<br />
pList is a pointer to the source CObArray-Object.
Add() adds an element in the destination CObArray-Object.
Now the problem:
*pElement2 = *pElement1 do not call the = operator of CA or CB. The = operators have no virtual behaviour. The result ist that not all elements (CBase and CA/CB) are copied. Only the = operator of CBase is called.
What is to do? And how can i call in the = operator function of CA the = operator funrction of CBase to copy the base elements?
And one more question:
What is the reason for the Cxyz& return type of the = operators and the return(*this) statement?
Thanx
Dr-Kuulun
|
|
|
|
|
operator= is not inherited and (I think) cannot be virtual. Polymorphism wouldn't apply to an assignment because the compiler has to know exactly what types are involved in an assignment. Each class is responsible for its own copying/assignment behavior.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
But the operator is represented by a function. Functions can be virtual. Why is it not possible for an operator? Now I wrote a virtual clone-function an the list class calls this function to copy the elements. This way works fine.
Dr-Kuulun
|
|
|
|
|
hi
i m using this code to for fileopen dialog with multiselection of files.
here is it
::OPENFILENAME ofn;
char *szFileName=new char[1024];
ZeroMemory(szFileName, sizeof(szFileName));
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0All Files (*.*)\0*.*\0";
ofn.lpstrFile =szFileName;
ofn.nMaxFile = 1024;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_READONLY;
ofn.lpstrDefExt = "bmp";
CString str;
if(GetOpenFileName(&ofn))
{
MessageBox(ofn.lpstrFile);
MessageBox(szFileName);
str=ofn.lpstrFile;//szFileName ;
CString temp;
str.Trim();
int index;
while(str.GetLength()>0)
{
index=str.Find('\0') ;
temp=str.Left(index);
MessageBox("The Extract:\t"+ temp);
str=str.Mid(index+1,str.GetLength());
MessageBox("The Remaing\t"+ str);
}
}
for single file selection it shows the full file name. for multiselection the ofn.lpstrFile contain only the directory name and nothing else i had shown that on the msgbox. it prints the directory. where in MSDN i read the after directory name then null and then file names are present. which are not.
Tasleem Arif
|
|
|
|
|
Your problem is here:
str=ofn.lpstrFile;
The CString will only contain up to the first NULL in the ofn.lpstrFile.
When the CFileDialog return OK, you need to do something like this:
pos = filedlg.GetStartPosition();<br />
while (pos != NULL)<br />
{<br />
name = filedlg.GetNextPathName(pos);<br />
m_pathlist.AddTail(name);<br />
m_pFileList.AddString(name);<br />
}<br />
m_pFileClear.EnableWindow(TRUE);<br />
m_pFileTouch.EnableWindow(TRUE);
That gets each file name selected and adds them to a CStringArray (m_pFileList) for later use.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
thanks for reply but i wanted to use only API not MFC class
char *pdes=::strchr(ofn.lpstrFile,'\0');
index=(int)(pdes-ofn.lpstrFile+1);
Drive=ofn.lpstrFile;
ofn.lpstrFile+=index;
while(strlen(ofn.lpstrFile)>0)
{
char *pdes=::strchr(ofn.lpstrFile,'\0');
index=(int)(pdes-ofn.lpstrFile+1);
str=ofn.lpstrFile;
ofn.lpstrFile+=index;
MessageBox(Drive+str);
}
dats solution i worked out thanks for answering me
Tasleem Arif
|
|
|
|
|
|
Hey Friends
I am trying to run a query like given below
select count(*) from table1
now when i try to read the value of the result using
GetFieldValue function
it gives exception that Value is big
I debugged the same & found that
the ODBCFieldInfo is treating the result as DBVT_SHORT hence if the value is large it is throwing an exception .
Any suggestions ?
|
|
|
|
|
Hey Friends
I wish to create a database viewer which can
a) list down records of tables
b) list down fields of tables
c) list down triggers of tables.
I am stuck when i am tryint to list down triggers of tables.
I am aware of CRecordset & CDatabae classes
|
|
|
|
|
Hey Friends
I got it
SELECT * FROM user_objects WHERE object_type='TRIGGER'
Now the problem is that how we can read the trigger details
i found using Desc statment
but how to run DESC using MFC ?
Thanks
|
|
|
|
|
What u meant by DESC statement ?
You can run this statement using ADODB.
use _RecordsetPtr->Open to execute the sql.
cheers...mil10.
|
|
|
|
|
Hey Thanks buddy
By saying DESC i meant the Trigger Details
I found a query for the same which i can run using CRecordSet & get the value
SELECT Table_name , Trigger_Name , Trigger_type , description, TRIGGER_BODY FROM ALL_TRIGGERS
Regards
|
|
|
|
|
If you want to develop a database program, i suggest u use VB - it is very easy to learn and very powerful for databse issues.
If you want to learn database in VC, i suggest u throw CRecordSet and all its related classes (i.e. CDatabase) away - they are very ugly. the best classes in VC are Cdatabase etc (d is lowercase) - they are very flexable and powerful, VB uses them at background. once u know Cdatabase etc, you are a master. u are a slave for forever if using CDatabase etc.
A special image tool for Windows C++ programmers, don't miss it!
The world unique Software Label Maker is waiting for you and me ...
A nice hyper tool for optimizing your Microsoft html-help contents.
|
|
|
|
|
hi,
Sorry for the intereption. My little experience in database suggest that
you should not use the MFC Database classes if you want to develop a database.
Instead use the "xxado.dll" to develop your app.
In the stdafx.h file write these lines
include <atlbase.h>
include <comdef.h>
#import "path\\xxado.dll" namespace "EOF, adoEOF"
Then use ur desired objects as follows:
CoInitialze(NULL);
IConnectionPtr pCon;
IRecordsetPtr pRes;
pCon.Open(connectionstring);
pRecordset.open(query,pCon ,etc);
...
CoUninitialize();
|
|
|
|
|
hi
i have open the XML File with the help of dynamic shoiab.
but the story do not end here. i want to print the vital information of the XML File into my Active document.
what should i do?i 'm very novice in vc++ that's why i'm facing such kind of problem so please some body help me.
thanx
Aavesh
|
|
|
|
|
1) Keep the xml data in the CDocument member variable.
2) Override the Ondraw method of CView,
3) Call GetDocument() on cview to get a poineter to the document object.
4) Get the xml values from CDocument mmebr and use pDC->DrawText to print the value.
cheers mil10.
|
|
|
|
|
hi
thanx for reply.
i have open the XML File using following code.
void CMainFrame::OnLoadxmlLoadxmlfile()
{
// TODO: Add your command handler code here
OpenXMLFile("E:\WorkingBigBoss\BigBossApp\books.xml")
//ReadXMLFile("E:\WorkingBigBoss\BigBossApp\books.xml");
}
bool CMainFrame::OpenXMLFile(const CComBSTR& bstrFileName)
{
VARIANT_BOOL bFlag;
_variant_t varFilePath;
CoInitialize(NULL);
if (m_pIDomDoc != NULL) //Declare it as member of ur class IXMLDOMDocument* m_pIDomDoc;
{
m_pIDomDoc = NULL;
}
if (m_pIDomDoc==NULL)
{
HRESULT hr = CoCreateInstance(CLSID_DOMDocument , NULL, CLSCTX_INPROC_SERVER , IID_IXMLDOMDocument ,
reinterpret_cast < void **> (&m_pIDomDoc));
if (SUCCEEDED(hr) && m_pIDomDoc!= NULL)
{
OLECHAR *oleFilePath = new OLECHAR[wcslen(bstrFileName) + 1];
wcscpy(oleFilePath, bstrFileName);
varFilePath = oleFilePath;
hr = m_pIDomDoc->load(varFilePath, &bFlag); //load the file in xmlDoc
if (SUCCEEDED(hr))
{
return true;
}
varFilePath.Clear();
delete []oleFilePath;
}
}
return false;
}
now why which command i can keep the xml data CDocument variable.
after it i will override the OnDraw method of CView & will call the getdocument on CView for document object.
but how i will get the XML values to put into CDocument member.
i hope u got me what i want to ask
byeeee
Aavesh
|
|
|
|
|
1) declare an _bstr_t variable say bstr in your CDocument
2) then, bstr = m_pIDomDoc->xml;
3) then, in the OnDraw method, write
CYourDocument* pDocument = (CYourDocument*)GetDocument();<br />
CString xml (pDocument->bstr);<br />
pDc->DrawText(xml, 0,0 );
cheers..mil10.
-- modified at 10:09 Saturday 1st April, 2006
|
|
|
|
|
hi sir,
i'm using following function to open a XML File.it returing a Bool value.i have given a Menu Option to open the XML File.i have decalred into mainfrm.h & mainfrm.cpp for it.so when i run the program & click on the appropriate menu option for open a XML File.it opens.
void CMainFrame::OnLoadxmlLoadxmlfile() //this is function which will called when somebody click on menu option.
{
// TODO: Add your command handler code here
if(OpenXMLFile("E:\WorkingBigBoss\BigBossApp\books.xml"))
{
AfxMessageBox("Hi Love");
}
//ReadXMLFile("E:\WorkingBigBoss\BigBossApp\books.xml");
}
bool CMainFrame::OpenXMLFile(const CComBSTR& bstrFileName)
{
VARIANT_BOOL bFlag;
_variant_t varFilePath;
CoInitialize(NULL);
if (m_pIDomDoc != NULL) //Declare it as member of ur class IXMLDOMDocument* m_pIDomDoc;
{
m_pIDomDoc = NULL;
}
if (m_pIDomDoc==NULL)
{
HRESULT hr = CoCreateInstance(CLSID_DOMDocument , NULL, CLSCTX_INPROC_SERVER , IID_IXMLDOMDocument ,
reinterpret_cast < void **> (&m_pIDomDoc));
if (SUCCEEDED(hr) && m_pIDomDoc!= NULL)
{
OLECHAR *oleFilePath = new OLECHAR[wcslen(bstrFileName) + 1];
wcscpy(oleFilePath, bstrFileName);
varFilePath = oleFilePath;
hr = m_pIDomDoc->load(varFilePath, &bFlag);
//load the file in xmlDoc
bstr = m_pIDomDoc->bstrFileName;
/* if (SUCCEEDED(hr))
{
return true;
}
varFilePath.Clear();
delete []oleFilePath;*/
}
}
return false;
}
above code is running succesfully.
so now u said i have to decalare a _bstr variable in cdocument.and what is xml.i know that i'm little confuse & bothring u.but sir please help u.
so what i want:- just give me the steps with the file name.
& what would be the relation of openXMLfile and ur steps.
thanx
Aavesh
|
|
|
|
|
I'm working in a metal workshop where we have the following challenge:
We produce driveshafts according to spec from a certain customer. They have many different specs for the driveshafts, requiring a lot of different lengths. According to the length requested, we cut 20 feet long 10inch thick steel bars into the appropriate lengths, but sometimes we end up with too much of the steel bars that go to waste. Which is costly in the long run.
I'm looking for an algorithm to solve this problem so that I can optimize cutting length for a certain number of driveshafts.
Say that I have x number of different length driveshafts to make. I want to calculate all permutations (ordered sets) of lengths, but in the process of calculating the permutations I also want to keep the total length of the y first driveshafts in the permutation so that it will be below, but as close to 20 feet as possible.
The program is supposed to receive as input the number of and length of driveshafts to produce, and generate as output optimized cutting lengths for the steel bars I need to spend in order to produce all driveshafts with as little waste of metal as possible.
Any suggestions with regards to how to code this thing? Or the permutation algorithm that is required?
TIA,
L.R
|
|
|
|