|
It is almost certainly possible to write your function in one line - but the advice that you are getting from professional programmers here is not to do that. What it does will be the same, the syntax just more complex.
If this is not simple enough for you, find a better way. Before you complain about the solution someone has bothered to give you, engage brain and think of what is involved (having one solution in front of you should help). In this case the simplest way I can see to round the contents of one edit box is to get the string, convert to a floating point representation, round and convert back to a string. If you can find a better way, we have shared one solution with you, please share yours with us.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
You're absolutely right !!!
Thanks !!
|
|
|
|
|
Hi
I have been using vc++ 6.0.The bscmake.exe utility which is meant
to create .bsc file is not able to execute.
When I build the application I get "Error executing bscmake.exe." at the end of the debug information and hence I am not able to avail the facility of source browser.
Can you please tell me how to solve my problem?
With Regards
Neeraj Sinha
|
|
|
|
|
Can i partition Router or Switch into trusted and untrusted network.
If yes which one is more advantageous and why also how this can be implemented.
I have three users to whom i want to provide access of data onto the servers(White users) and three user to be denied the same(Black users).
So please advise whether Router or switch is feasible.
Arvind kumar sharma
software Developer
|
|
|
|
|
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
In my application I need to read/write values to/from certain cells in an excel sheet.
I've imported the Microsoft Excel 11.0 Object Library and added all the required interfaces (I think).
My question is how do I open an existing XLS file and how do I get or set values from a certain cell?
Thanks in advance,
Guy.
|
|
|
|
|
Dear friend,
I think Shellapi.h might be of your help. Once I used it to open an text and excel file. Dont know specific functions right now. ShellExecute() will help. I think.
Nikhs
Nikhil Trivedi
|
|
|
|
|
GuyM wrote: how do I open an existing XLS file
I think the ShellApi.h would be of your help. You can get its detail from msdn.com. I think the ShellExecute() function will do for you.
Hope this would help you.
|
|
|
|
|
Thanks for your answer, but I want to programmatically read/write values to/from excel (not just run the excel application).
This is done with COM ... I've found an example in MSDN but:
1. It doesn't show how to open an existing file.
2. It only shows how to read/write an entire range of cells, not a single cell
Thanks.
|
|
|
|
|
Sorry that I got your question wrong. I havent worked on office tools, but one of my friend who worked on this told me that he was using excel.h then. I dont know if it might help you or not.
Nikhs
Nikhil Trivedi
|
|
|
|
|
An existing excel document is opened with Open(...) in the Workbooks interface.
Do you have a link to the MSDN example?
Perhaps the explanation becomes more clear if it's based on the example you've based your code on.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
This is the link to the example:
http://support.microsoft.com/kb/308407[^]
As you can see there, the example doesn't open an existing excel file but creates a new (unnamed) one. Second, is uses COleSafeArray in order to access (read/write) an entire range of cells, where I need to access only single cells ...
Thanks for your help ...
|
|
|
|
|
Before you continue you have to be aware that Excel deals with containers.
This means that when you launch Excel with CreateDispatch or similar, the next step is usually to get an interface for the WorkBook collection/container called WorkBooks .
The same goes for the WorkSheet objects in the WorkSheets collection/container and so on.
Once you've got hold of the WorkBooks interface, you call WorkBooks::Open(...) in order to open an existing document, a WorkBook . Then you'll get a WorkBook interface to be able to access the document.
When the WorkBook has been opened, you have to choose which WorkSheet you want to use with WorkBook::get_WorkSheets() and later WorkSheets::get_Item(...) .
For each cell you want to read or write, you have to select a "Range". The example shows this.
Regarding the fact that you don't want to use a SafeArray to write the data, I think you can give a VARIANT as argument to Range::put_Value() with a single value and the type set to e.g. VT_I4 for a 32-bit integer.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
GuyM wrote: My question is how do I open an existing XLS file...
if (app.CreateDispatch("Excel.Application") == TRUE)
{
app.SetVisible(TRUE);
Workbooks books = app.GetWorkbooks();
_Workbook book = books.Open("C:\\Book1.xls",
vtOptional, vtOptional, vtOptional,
vtOptional, vtOptional, vtOptional,
vtOptional, vtOptional, vtOptional,
vtOptional, vtOptional, vtOptional);
...
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Great - it worked !! Thanks !!
Now just one more thing ...how do I get/set the value a certain cell (for example A1).
|
|
|
|
|
GuyM wrote: ...how do I set the value a certain cell (for example A1).
Worksheets sheets = book.GetSheets();
_Worksheet sheet = sheets.GetItem(COleVariant((short) 1));
Range range = sheet.GetRange(COleVariant("A1"), COleVariant("A1"));
range.SetValue(COleVariant("12345.6"));
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
HI i want to set a particular cell to RED color ??
and also while quittin the application, the excel file need to be saved....
|
|
|
|
|
hellogany wrote: HI i want to set a particular cell to RED color ??
Range range = sheet.GetRange(COleVariant("A1"), COleVariant("A1"));
Interior interior = range.GetInterior();
interior.SetColorIndex(COleVariant(3L)); hellogany wrote: and also while quittin the application, the excel file need to be saved....
So you might want to call Save() or SaveAs() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
thanks for the reply.
i have to find a value in the excel cell and should replace a new value in that cell
Can u help me on this issue?
gany
|
|
|
|
|
hellogany wrote: i have to find a value in the excel cell...
Look at the Range::Find() method.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
DavidCrow wrote: Range range = sheet.GetRange(COleVariant("A1"), COleVariant("A1"));Interior interior = range.GetInterior();interior.SetColorIndex(COleVariant(3L));
I've been looking all over for how to change the color - thanks to you it works - but just a simple question- Why is 3L = red? How does this color index thing work? Is there a way to use RGB with the 3 params to get any color?
Thank you again!
Mike
|
|
|
|
|
thready wrote: Why is 3L = red?
Because that's what the designer of that type library decided.
thready wrote: How does this color index thing work?
I'm not sure what you are asking here. Just use the OLE/COM Object Viewer to find out the other values.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
just make a dialog with mfc-wizard.
add message function like this
void CTest::OnLButtonDown(UINT nFlags, CPoint point)
{
PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x,point.y));
CDialog::OnLButtonDown(nFlags, point);
}
and exacute it.
1) click the client area of dialog with left mouse button.
2) move it toward screen top
3)when the some part of dialog is in off-screen, release mouse left button.
4)automatically the dialog is moved again to screen area. <= it is my problem.
normal window acts like this.
how can I disable 4) action?
I want to prevent the dialog from automatically moving back onto screen.
thank you in advance.
<hello world="">
|
|
|
|
|
david_joung wrote: automatically the dialog is moved again to screen area.
Use DM_REPOSITION message to move dialog back onto screen.
|
|
|
|
|
david_joung wrote: 4)automatically the dialog is moved again to screen area. <= it is my problem.
So what exactly are you wanting to happen?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|