|
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
|
|
|
|
|
The reply is a little late, however I have had some dealings with this sort of code in the past.
Take a look here[^] where you will find an introduction to the algorithms you are looking for. Obviously you won't be dealing with playing cards, so you would want to enter the lengths of the required drive shafts and try various combinations.
I am unable to help any further since really I need to know exactly what sort of data you are dealing with, how often you would enter/update the data, how much time it takes to use a full 20 foot bar, how many of the same item are usually ordered, how you keep track of your stock... etc. All these will take a part in producing an efficient algorithm.
I once created something similar for an exhaust manufacturer, who wanted an efficiency algorithm for cutting up sheet steel. Here they would get an order for a single type of exhaust. The algorithm had to keep track of the current stock (remaining pieces) and determin which was the best to use leaving enough to spare for awaiting orders.
|
|
|
|
|
Hi friends,
I develop one application. I retrieve values from variable and add it to text file. when I click Add button, records are added into file. I also display data from file in List control.But one problem is occur. when I add record and click on show button, first record display two times. I close file , and again execute application and add new record, and click on show button now earlier record display one time and new entry is shown 2 times.
sample code on Display button, with the help of this code I display record in list control
fstream file("D:\\Mfctut\\kdr.txt",ios::out |ios::in );
do
{
file.read((char*)(&kdr),sizeof(kdr));
int nIndex = m_Listvw.InsertItem(0,"");
m_Listvw.SetItemText(nIndex,0,kdr.name);
m_Listvw.SetItemText(nIndex,1,kdr.address);
}while(file.eof()!=TRUE);
kindly give me a reply.
Regards
kedar
Girish
Software Developer
|
|
|
|
|
can not find different code for "earlier record" and "new entry".
check if "add new" function is called for twice, try add a flag to ensue it is called for only once:
MyClass::ClickButton()
{
//the bool value is initialized as 0 before in constructor.
b_AddNew=1;
AddNewFunction();
}
MyClass::AddNewFunction()
{
if(b_AddNew==0) return;
b_AddNew=0;
do
{
//your code
}while(...);
}
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.
-- modified at 13:00 Saturday 1st April, 2006
|
|
|
|
|
I can't find what is wrong. But you should place the while-statement at the beginning of the loop. Your loop will show wrong data or crashes if you open an empty file.
Dr-Kuulun
|
|
|
|
|
hi Dr-Kuulun,
I received your response. I will try to solve out problem. Thanks for give me a reply.
Regards
kedar
Girish
Software Developer
|
|
|
|
|
hello everyone,
my application is MDI application develop in 1998. when i want to find or replace something it find it reverse ,if cursor is at just start or just end , it did not work.
i have tried to make my own find portion by defining structure FINDREPLACE
but failed.
but when i make a new application , it works perfectly well
plz tell me the solution
how i can resolve this problem . basically it's a MFC function
is ther could be any pointer problem??????
plz response
sachin gupta
sachin gupta
|
|
|
|
|
Hi,
I want to draw a line
(2 points , start of line ->lbutton down, mouse move (rubberband), end of line->lbutton down)
Its drawing perfectly. I have put the rubberband effect in mose move handler, but my rubberband line is not clearly visible. Its like dotted line and that too not clear. Why is that so? I have put pDC->SetROP2(R2_NOTXORPEN ); I tried with R2_NOT or some other combinations too.
My background color is black. I have also giving the code of OnEraseBkgnd handler.
My code is as follows.
void CMysplashView::OnLButtonDown(UINT nFlags, CPoint point)
{
CClientDC dc(this);
if(theApp.drawGraphic)
{
if(!fpoint)
{
m_ptold=point;
fpoint=true;
SetCapture();
}
else
{
CPen pen (PS_SOLID, 1, RGB(255,255,255));
CPen *oldpen = dc.SelectObject(&pen);
dc.MoveTo(m_ptold);
m_pt=point;
dc.LineTo(m_pt);
dc.SelectObject(oldpen);
fpoint=false;
ReleaseCapture();
}
dc.SetPixel(point, RGB(255,255,255));
}
CView::OnLButtonDown(nFlags, point);
}
BOOL CMysplashView::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
pDC->GetClipBox(&rect);
pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), BLACKNESS);
return 1;
}
void CMysplashView::OnMouseMove(UINT nFlags, CPoint point)
{
if(GetCapture()!=this)
return;
// TODO: Add your message handler code here and/or call default
if(theApp.drawGraphic)
{
if(fpoint)
{
CDC *pDC=GetDC();
CPen pPen(PS_SOLID,1,RGB(0,0,0));
CPen *pPenOld = pDC->SelectObject(&pPen);
pDC->SetROP2(R2_NOTXORPEN );
m_pt = point;
pDC->MoveTo(m_ptold);
pDC->LineTo(m_pt);
pDC->MoveTo(m_ptold);
pDC->LineTo(m_pt);
pDC->SelectObject(pPenOld);
ReleaseDC(pDC);
}
}
CView::OnMouseMove(nFlags, point);
}
Thanks
Lee
|
|
|
|
|
Hi yang__lee ,
what's theApp.drawGraphic? I get many erros?
anyway I run your code It draw a background black and when I click lButton in the screen it draw
dot
maybe it is some helpful to you please check function mousemove
do you need to draw line in the form with LButton click ?
|
|
|
|
|
I am developing an app, which creates a DUN entry programmatically. The issue I am facing is that, how do I set-up the modem properties like baud rate, h/w flow control, etc. for the modem device I have specified for the entry. Also, how do I change the default settings for a modem like init strings, etc.?
Thanks,
Krishnan
|
|
|
|
|
1) Call GetCommState( handle, &dcb ); to get the existing port settings into DCB .
2) Modify the DCb structure accordingly to set new values.
3) Call SetCommState to set the new values back to port.
rgds...mil10.
|
|
|
|