|
Hello,
I am working on an RFQ scanner program written in C++. I would like to use the classWizard to create various recordsets. This program is run through a telnet application called SLNET to the scanners. Can I convert this program to MFC? If so will it still work through the telnet program?
If you can't can I create another app, then create the classes for the ODBC recordsets, and cut them into my program?
Thanks.
|
|
|
|
|
I thought Microsoft had a conversion program that would take
something like a console mode app and convert it to MFC.
Unfortunately, Ive long since forgotten/buried the reference
for it.
I had a contractor in my shop covering my butt while I was
on annual leave earlier this year and he passed the
info on when we were talking about 'legacy c code conversion
to MFC'). Apparently, it presumes a certain 'style'
of programming, so it might not do 100% unless you end up
doing a re-factor/re-write. This also may not help, since
you're starting from C++.. in my case, the contractor started
with a mish-mash of c, C++, and rewrote the service using
the ATL COM Service wizard as a base, with MFC support, then
added back my classes.
Hope you find something useful in this ...
Garth
|
|
|
|
|
Hey all!
You know how when you connect to the internet and you double click the little computer icon in your systray how it has a button which says Details and when you click it, the window extends downward? I want to do something similar in my app where when you click it, it reveals more buttons and extends the dialog window! how can I do this?
Thanks
Ashman
|
|
|
|
|
Easy Peasy. Put the button where you want the boundary to be and when you press it, call SetWindowPos with SWP_NOMOVE and SWP_NOZORDER, and use the text on the button to know which values to pass ( the short dialog or the full one ). That way you can grab the button position and use it, allowing you to move it in the template if needed and automatically have it work for you where-ever it is. Beats spending ages trying values every time it changes.
Christian
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
Hi,
Once again I'm banging my head against this ADO stuff. Here's my prob:
I have an array of pointers to CADORecordBinding objects. I want to associate each object in the array with a record from the database.
Problem is If i call pBndRs->BindToRecordset(pVisitRs) for each new object, I get a com_error. I've also tried increasing the reference count for pVisitRs but this fails too.
<br />
IADORecordBinding * pBndRs;<br />
CVisitBndRs * pVisitBndRs;<br />
_RecordsetPtr pVisitRs;<br />
<br />
TESTHR(pVisitRs->QueryInterface(__uuidof(IADORecordBinding), (LPVOID*) &pBndRs));
<br />
while (!pVisitRs->GetadoEOF())<br />
{<br />
pVisitBndRs = new CVisitBndRs();
m_visitBndArray.Add(pVisitBndRs);
TESTHR(pBndRs->BindToRecordset(pVisitBndRs));
pVisitRs->MoveNext();
}<br />
So I end up with the first object in the array getting the values of the most recent record, and all the rest contain junk.
Any help greately appreciated..
But for now my brain must rest for the weekend
Regards
Brendan
|
|
|
|
|
I'll just reply to my own problem, in case anyone encounter the same situation.
Its probably better to write your own class which has a copy constructor which accepts a CADORecordBinding object as a paramater. If you want to save information back to the database, just iterate through the array and you'll have to create a new CADORecordBinding object, which is a bit of a pain. This approach allows you to incorporate additionally functionality in terms of member functions in your own class.
|
|
|
|
|
Hi Brendan.
I have question of you,
You used of ADO DLL in your program or you used of ADO OCX ???
When i use of DLLs in my program then i use of classes, or only functions (for example direcx dll)?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I've tried various pieces of sample code to find the system tray window, and the system clock window, but none of them seem to work. I even tried searching for the window by title, creating a title from the current time. No go. What I want to do it force the clock to redraw after I've updated the time.
Anybody had success in this area?
Peter
|
|
|
|
|
After more searches, I found it.
::SendMessage(HWND_TOPMOST, WM_TIMECHANGE, 0, 0);
Peter
|
|
|
|
|
hello,
I want to disable the keyboard prog'cly.I wrote a keyboard hook but got struck up in the middle.I want to furhter know if there is any other way to disable the key board prog'cly
other than hooks.
thanx in advance
Anil
|
|
|
|
|
I doubt it. If you don't hook the system, how can you stop the system responding to the keyboard ???
Christian
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
ya graus ,
I could write to hook a particular vkey .when it comes to the entire keyboard,how do i access the entire keyboard???.
My doubt is by useing these keybrd functions like setkeyboardstate,getkeyboardstate,keybd_event can't we disable the keybrd for a particular application.of course i couldnot do it.I thought may be, i went wrong in some
implimentations.Do correct me if i am wrong.
Thanx in advance
Anil
|
|
|
|
|
Most examples of system wide hooks use the keyboard hook - it by definition means that your code intercepts every press of the keyboard, hence it is used to stop CTRL-ALT-DELETE working. Look up WH_KEYBOARD in the MSDN for more info.
Christian
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
beginner question
this code reads from keyboard and writes to file ok, but won't display on sreen before ending progam, it is like it's skipping over the "customerdisplay()" function, and not printing to screen, i thought it should, could somebody explain what is wrong
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <conio.h>
using namespace std ;
//Function: To read from keyboard and write a file
void customerinfo();
//Function: To read file into struct and write to display
void customerdisplay();
struct phone_customers
{
string name, address, city, business_description,state, zip, credit_limit, customer;
int phone_num;
};
phone_customers order;
ofstream outfile;
ifstream infile;
string dummy;
int main()
{
customerinfo();
customerdisplay();
getch ();
return 0;
}
void customerinfo()
{
outfile.open ("orders.txt");
cout << "Phone Number (Enter -999 to quit):" << endl;
cin >> order.phone_num;
while (order.phone_num != -999)
{
getline (cin, dummy);
cout << "ENTER NAME: " << endl;
getline(cin, order.name);
cout << "ENTER ADDRESS: " << endl;
getline(cin, order.address);
cout << "ENTER CITY: " << endl;
getline(cin, order.city);
cout << "ENTER STATE: " << endl;
cin >> order.state;
cout << "ENTER ZIP: " << endl;
cin >> order.zip;
cout << "CREDIT LIMIT OF CUSTOMER: " << endl;
cin >> order.credit_limit;
cout << "If customer is a business enter T, or if individual enter F" << endl;
cin >> order.customer;
outfile << order.name << " " << order.address << " " << order.city << " "
<< order.state << " " << order.zip << " " << order.credit_limit << " "
<< order.customer << endl;
cout << "Phone Number: " << endl;
cin >> order.phone_num;
}
outfile.close();
return;
}
void customerdisplay()
{
infile.open ("orders.txt");
infile >> order.phone_num;
while (!infile.fail())
{
infile >> order.phone_num >>order.name >>order.address>>order.city>>order.state>>order.zip>>order.credit_limit>>order.customer;
cout << order.phone_num << order.name << " " << order.address << " " << order.city << " "
<< order.state << " " << order.zip << " " << order.credit_limit << " "
<< order.customer << endl;
infile >> order.phone_num;
}
infile.close ();
return;
}
|
|
|
|
|
Hello, the codegurus around the world.;)
One possibility is that "return" in customerinfo() and in customerdisplay();
I think that "return" ends this program.
int main()
{
customerinfo();
cout << "After customerinfo() << endl;
customerdisplay();
cout << "After customerdisplay() << endl;
getch ();
return 0;
}
We can always put cout to find which lines is reached if we don't have the debugger.
But, I think that you use VC 6.0?
Last, I didn't check your code in detail, and basically, try to do your homework by yourself.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
You're gonna kick yourself....
The new function to write out the file looks like this:
void customerdisplay()
{
infile.open ("orders.txt");
while (!infile.fail())
{
infile >> order.phone_num >> order.name >> order.address >> order.city >> order.state >> order.zip >> order.credit_limit >> order.customer;
cout << order.phone_num << order.name << " " << order.address << " " << order.city << " "
<< order.state << " " << order.zip << " " << order.credit_limit << " "
<< order.customer << endl;
}
infile.close ();
return;
}
You were reading in the number BEFORE reading it for the first time, and again AFTER you read the whole schmeer at the end of a 'while' iteration. Some other points:
This only works if each input string has no spaces in it, otherwise it tries to seperate by spaces. A better way would be to read a line at a time and cut it up using you own token ( TAB maybe, \t ) and therefore maintain things like an address which will usually have 2 or three 'words' in it.
This also only works if the phone number is a number, not a string. If you're going to save as a number, it's best to make sure you've been given one.
Christian
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
I've got a CListCtrl in a dialog that selects a row. The problem is that the selection disappears when I click on a another control in the dialog and the focus moves there. How can I make the CListCtrl continually show the selected row, without going to custom draw, etc?
Thanks.
Peter
|
|
|
|
|
modify the List Control to use LVS_EX_SHOWSELALWAYS, eg
void MyDialog::OnInitDialog ()
{
...
m_myList.SetExtendedStyle (m_myList.GetExtendedStyle() | LVS_EX_SHOWSELALWAYS);
...
}
hope this is what you need
nb
|
|
|
|
|
Thanks, that pointed me in the right direction. It doesn't quite work that way, so I need to do something like this:
CMyDialog:OnInitDialog...
CRect rcWin;
m_ListCtrl.GetWindowRect(&rcWin);
ScreenToClient(&rcWin);
DWORD nStyle = m_ListCtrl.GetStyle();
UINT nID = ::GetWindowLong(m_ListCtrl.m_hWnd,GWL_ID);
long nExStyle = m_ListCtrl.GetExtendedStyle();
m_ListCtrl.DestroyWindow();
m_ListCtrl.Create(nStyle | WS_BORDER | LVS_SHOWSELALWAYS, rcWin, this, nID);
m_ListCtrl.SetExtendedStyle(nExStyle | WS_EX_WINDOWEDGE);
Still haven't figured out how to get the standard 3-d border on the listcontrol. Tried all sorts of WS_ and WS_EX_ but it doesn't seem to go. May have to leave it that way.
Peter
|
|
|
|
|
Instead of re-creating the window, select the 'show selection always' option in the list control properties in dialog editor.
> Still haven't figured out how to get the standard 3-d border on
> the listcontrol. Tried all sorts of WS_ and WS_EX_ but
> it doesn't seem to go
Are you creating your list control programatically (CListCtrl::Create), or in dialog editor?
Tomasz Sowinski
http://www.shooltz.com.pl
|
|
|
|
|
Yes, that's exactly what I was looking for. Thanks!
Peter
|
|
|
|
|
Hi All!
Doing some work with SQL Server, getting out this horrendous datatype called DB_NUMERIC - Converting DB_NUMERIC to anything useful looks like a nightmare. It is a decimal value stored as an array of 16 bytes, + a sign, + a precision. I particularly need to convert it to a string ... can anybody help me???
Thankyou, and happy coding
NB
|
|
|
|
|
for anyone else in this situation:
I just solved the prob, you need to use IDataConvert ... look it up in MSDN
cheers
NB
|
|
|
|
|
Okay, so I have this multi-threaded app. It shows a dialog with a 'Start' button on it. You click start, it starts a thread. That thread in turn starts a user specified number of other threads that do actual work and block when they finish( See CThread::WaitForEnd() ).
The problem is, if I specify a large number of threads, some of them never end. i.e. Start 100 threads, wait until they stop (WM_TIMER sets a mutex protected BOOL), the debug window shows 0xNNNN exited etc. but locks up before they all exit (i.e. 80 will but the last 20 won't). Task manager says there are still threads open ( 10, 20, 30 etc. ). What on earth would cause this behaviour??? Can anyone help?
NB: I got it to do an unhandled exception on a call to WaitForSingleObject() in CThread::WaitForEnd(). I can't reproduce it however so I don't know if it has anything to do with the problem...
UINT CDlgBlah::ThreadProc()
{
CThread* arrThreads = new CThread[ dwThreadCount ];
hMutex = CreateMutex( NULL, FALSE, NULL );
for( DWORD dw = 0; dw < dwThreadCount; dw ++ )
{
arrThreads[ dw ].m_rnd = rand() % RAND_MAX;
arrThreads[ dw ].Begin()
}
for( dw = 0; dw < dwThreadCount; dw ++ )
arrThreads[ dw ].WaitForEnd(); // ##### Stops here
// ##### Never gets here
AfxGetMainWnd()->SendMessage( UWM_SHOWRESULTS ); // Update display (safe?)
return 0;
}
class CThread : public CObject
{
public:
CThread();
virtual ~CThread();
BOOL Begin( void );
void WaitForEnd( void );
void DoWork( void );
static UINT ThreadProc(LPVOID pObj);
int m_rnd;
private:
CWinThread* m_pThread;
}
BOOL CThread::Begin()
{
m_pThread = AfxBeginThread( ThreadProc, this );
return m_pThread != NULL;
}
UINT CThread::ThreadProc( LPVOID pObj )
{
CThread* pThread = (CThread*)pObj;
pThread->DoWork(); // Do some work
return 0;
}
void CThread::WaitForEnd()
{
WaitForSingleObject( m_pThread->m_hThread, INFINITE );
}
void CThread::DoWork()
{
srand( rnd );
while( StillWorking() ) // WaitForSingleObject in here etc.
Sleep( rand() % 250 )
}
|
|
|
|
|
When sending from threads, do not use SendMessage().
This can block. Use PostMessage(), this won't block.
If you want to ensure you don't wait too long when sending, use SendMessageTimeout().
I recommend PostMessage(), its what I use and I haven't had any problems.
Stephen Kellett
|
|
|
|