|
Hi i have a dialog box where i have enabled the scroll bars by using the horizontal and vertical scroll bar check boxes in the dialog properties box
my question is how do actualy get the scroll bars so i can control them etc
thanks
|
|
|
|
|
Hi,
I have enabled editing of the labels on the tree control and I want to see what user has edited in the label in the
OnEndlabeleditTree () function, so that I can either commit the change or, reject the change.
what should I use the check the user input in the label?
code:
void CGeneratorView::OnEndlabeleditTree(NMHDR* pNMHDR, LRESULT* pResult)
{
TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
HTREEITEM hItem = pTVDispInfo->item.hItem;
if () //check edited text ?????????????????????????????
{
*pResult = TRUE;
}
else
{
*pResult = FALSE;
}
}
|
|
|
|
|
pTVDispInfo->item.pszText has the text, but if the user canceled the editing then it will be NULL. So you might do something like:
<br />
LPCTSTR lpszText = pTVDispInfo->item.pszText;<br />
if (lpszText != NULL && IsValidText(lpszText))<br />
{<br />
*pResult = TRUE;<br />
}<br />
else<br />
{<br />
*pResult = FALSE;<br />
}<br />
where IsValidText is some function you write to check the edited text.
|
|
|
|
|
from the code from MSDN i was able to open Excel and write to it. I would like a few more changes which I am not very sure as to how to implement .
1. How do i provide a fileName at the beginning instead of creating a new one and add data to a file . As of now I am creating a new WorkBook like
Workbooks books = app.GetWorkbooks();<br />
_Workbook book = books.Add(covOptional);
I want to be able to open an xls file as the current workbook and make changes to it !
2. I have a scenario where I have a lot of dynamic data in a tabular format(in a Grid control) in my Vc++ dialog application .I realise that I need to have a safearray , poplulate it with the data I need and then tie it to the range .
Do I have to precalculate the range that I am gonna be writing ? If yes then do I always need to Get a range using excel notation like
A-F ,AA-Af , BA-Bf and so on . That means that i might have to have some kind of mapping between my tables column number to the excel notation . Any efficient ways of doing this in case there is no other way out ?
if not i assume i can specify the range as absolute column numbers starting from 0 till the count of columns in the table i wish to export .
please advise .
|
|
|
|
|
1. The workbooks collection has an 'Open' method, as well as 'Add', which takes a number of arguments, many of which are optional.
Something like
_Workbook book = books.Open(COleVariant("file.xls"),covOptional,COleVariant(0));
should do the trick to open a given file. The second arg is whether to update links, the third is the readonly argument. You need to look at the VB help for the Excel object model.
2. To an extent, you'll need to calculate anyway to make your safearray the right size. You can specify the range as absolute column numbers anyway, but something like this will convert to AZ notation...(make sure result points to a big enough buffer)
<br />
TCHAR* RCtoString(long row, long col, TCHAR* result)<br />
{<br />
if (!result) return result;<br />
if (col > 26)<br />
{<br />
_tsprintf(result, _T("%c%c%d"),<br />
_T('A')+(col-1)/26-1,<br />
_T('A')+(col-1)%26,<br />
row);<br />
}<br />
else<br />
{<br />
_tsprintf(result, _T("%c%d"),<br />
_T('A')+(col-1)%26,<br />
row);<br />
}<br />
return result;<br />
}<br />
Hope this helps...
Steve S
|
|
|
|
|
Thanks for all ur answers.
I ve already tried to use another PC heaps of times, (and send everything to the hyperterminal). The communication between the hyperterm and the PC definitively works, I can receive/send data from/to the hyperterm.I ve also tried to use a sniffer when the hyperterm is connected to the external device and then compare with what my prog sends to this external device. And ..I send exactly the same apart from setmask and waitonevent. But I do not think it makes any difference since the hyperterm uses an overlapped communication .
I ve tried, as well, to use the acivex control provided by Visualc++ (MSCOMM32.ocx) and a couple of other activex controls found on the web.
Can it be something at a lower level ?Like something wrong in window for instance?
Thanks
sysy
|
|
|
|
|
I have been painfully supporting NT 4.0 using VC6 in many of my in-house projects. We are upgrading so that everyone will have at least Win2k. I know I can define _WIN32_WINNT 0x0500. My question is will this cause me incompatibilities with MFC or other libs? I know there is an article on this site here[^]that talks about a problem with MFC and CFileDialog but it is 3 years old and I am not sure that it is accurate.
John
|
|
|
|
|
Microsoft has not made any significant change to MFC. Other libraries really depends on what you actually are using.
|
|
|
|
|
There have been significant changes to some parts of MFC in VC7, CString for instance used to be reference counted in VC6, but is now an extension of basic_string in VC7. I think the upgrade to VC7 is much more frightening than the OS upgrade because a lot of compiler changes have been incorporated. Everything is manual, even memory leak detection has to be implemented manually, by dumping the leaks at the appropriate times for each project. Other than that you should have now problem specifying 0x0500 flag because 99% of all compiler version checking uses if(_WINNT >= blah) so if it compiles on NT 4.0 using a lower bit flag it'll compile on the Win2k .
|
|
|
|
|
*now problem*, bah, meant NO problem.
|
|
|
|
|
In my MDI MFC app, I have a status bar pane that shows the current line number and column number. I know that to get the current line number, I simply do: int lineNumber = LineFromChar( -1 ). But I am having trouble getting the current column, anyone know how to do this? It shouldn't be too bad.
|
|
|
|
|
I believe something like this would work. If ctrl is your control and lineNumber is the current line number:
<br />
int GetColumn(int lineNumber)<br />
{<br />
long start, end;<br />
ctrl.GetSel(start, end);<br />
<br />
return (start - ctrl.LineIndex(lineNumber));<br />
}<br />
|
|
|
|
|
Which is the most efficient way to restart my dialog box application, I mean to close the application and to start it again immediately after that.
|
|
|
|
|
Hmm if design allows, I would hide all dialogs visible, spawn a new instance of the application and then finish the original instance. For user it will look the same, only problem can be in accessing shared resources (disk file or whatever) but you can take a care about that.
|
|
|
|
|
Is it possible to run a CGI program in a web server from a C++ client application?
TIA
Carlos
|
|
|
|
|
That depends... is IE or Netscape written in C++?
|
|
|
|
|
Anonymous wrote:
That depends... is IE or Netscape written in C++?
What???
Do you think that will help to answer my question?
Carlos
p.s. both IE/Netscape are written in C/C++
|
|
|
|
|
you asked ... "Is it possible to run a CGI program in a web server from a C++ client application?"
IE/Netscape are client applications that send request to web servers. Sometimes these request result in the web server executing a CGI. So I guess maybe that the answer to your question is YES.
|
|
|
|
|
Yep, you're right, my question was not very clear
I should have written, how can I run a CGI program in a Web server from my C++ application? In other words, how can I send a POST/GET command from my app to a CGI-bin program?
Hope that makes sense now.
Thanks,
Carlos
|
|
|
|
|
IIRC, You can simulate POST by running the program, and dumping the data stream into its text input stream, and for GET you use some environment variable instead.
It was years ago I did any CGI stuff, that's all I can remember, so YMMV.
--
Ian Darling
If I was any more loopy, I'd be infinite.
|
|
|
|
|
There are a lot of ways to do it. You can open a socket and implement the (relatively simple) HTTP protocol to send the raw bytes for a GET or POST and interpret the results. Or you can use an existing HTTP implementation in a library or the WinInet functions in the Windows API. Look in MSDN for HttpOpenRequest
|
|
|
|
|
yes, all you need is connect to your target server on port 80, and give it a post or get request.
Use sockets.
when you connect to the machine on 80,
send data on the socket like this ..
GET /yourfolder/yourfile.cgi HTTP/1.0\n
User-Agent: Cool Browser 3.3\n
Host: www.yourmachinehere.com\n
Accept: */*\n
After you send that on the socket, your response will look like
'
HTTP/1.0 good request
some other stuff...
then it will send you the output (cgis output, or requested file if you get htmls/ images etc. )
'
sockets, and http protocol man. i dont remember the post syntax or id write it here too, just google the http rfc's for reference.
todo....
:: insert inpirational text here ::
|
|
|
|
|
Can anybody give me some useful advise on this problem I am having? Here's the code that is blowing up.
BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
if (!m_wndMainSplitter.CreateStatic(this, 2, 1, WS_CHILD | WS_VISIBLE))
{
TRACE("Failed to CreateStaticSplitter\n");
return FALSE;
}
cout << "DEBUG 1 WooHoo I got this far!" << endl;
// First main splitter pane
if (!m_wndMainSplitter.CreateView(0, 0, RUNTIME_CLASS(CCube_IView),CSize(300,300), pContext))
{
TRACE("Failed to create top view pane\n");
return FALSE;
}
// The code doesn't get this far!
/*
* Debug Assertion Failed!
* Program : blah
* File: winsplit.cpp
* Line: 364
*/
cout << "DEBUG 2" << endl;
....
|
|
|
|
|
I haven't checked my splitter code - but putting streams (cout) in there might screw it up.
|
|
|
|
|
- Run the program under the debugger;
- Wait for the assertion message box to appear;
- Hit Retry;
- Inspect the call stack to see how pView ended up being NULL
I mention those steps because it looks like you're trying to debug by inspecting console output. That rarely works. Instead, use the power of the debugger - inspect variables, step into suspect code, experiment.
|
|
|
|