"Remy Lebeau (TeamB)" <gambi...@yahoo.com> wrote in message
news:3e91fc7c@newsgroups.borland.com...
Quote
> "Richard Gratias" <rgrat...@sk.sympatico.ca> wrote in message
> news:3e91e57e@newsgroups.borland.com...
> > Using the grid example uploaded to borland.public.attachments
> > for model railroads, I am to the point of saving and loading files,
> > which of themselves appears to come out Ok.
> Are you referring to the sample I created for you?
Yes.
Quote
> > However, upon clicking the Open button (or double clicking
> > the file name) of the open dialog box, wherever the mouse is
> > pointing at that instant, after the file is finished loading all the
grid
> > cells are highlighted (in blue) in a rectangle from cell 0,0
> > (except 0,0 itself) to the mouse pointer as the lower right corner.
> What does your actual source code look like? Please post a sample which
> reproduces the problem that people can actually look at. Since my earlier
> sample did not have any open dialog, I can't reproduce your problem with
my
> earlier code.
> Gambit
Remy, the revisions I made to your sample include:
-- creating an integer array I call GridArray whose elements are initialized
to -1 in the constructor
-- Grid Array is set to the imagelist index number in OnDrawCell thus,
GridArray[Row][Col] = CellData[Row][Col].ImageIndex;
-- writing the save and load functions as follows
void TForm1::SaveFilBtn() {
if(GridSavDlg->Execute()) {
GridSavDlg->FileName = ChangeFileExt(GridSavDlg->FileName, ".dpr");
ofstream outfile(GridSavDlg->FileName.c_str());
for(int x = 0; x < DrawGrid1->ColCount; ++x) {
for(int y = 0; y < DrawGrid1->RowCount; ++y)
outfile << GridArray[y][x] << " "; } IsDirty = false; } }
void __fastcall TForm1::OpnFilBtnClick(TObject *Sender) { if(CanClose()) {
if(GridOpenDlg->Execute()) { if(!FileExists(GridOpenDlg->FileName))
MessageBox(0, "Unable to open file", "File Error", MB_OK |
MB_ICONEXCLAMATION);
else { Caption = " D I S P A T C H E R P A N E L --- " +
UpperCase(GridOpenDlg->FileName);
TCursor oldCursor = Screen->Cursor; Screen->Cursor = crHourGlass;
ifstream infile(GridOpenDlg->FileName.c_str());
for(int x = 0; x < DrawGrid1->ColCount; ++x) {
for(int y = 0; y < DrawGrid1->RowCount; ++y) {
infile >> CellData[y][x].ImageIndex;
GridArray[y][x] = CellData[y][x].ImageIndex;
DrawGrid1->Perform(WM_LBUTTONDOWN, 0, 0); } }
DrawGrid1->Perform(WM_LBUTTONDOWN, 0, 0); DrawGrid1->Invalidate();
IsDirty = false; Screen->Cursor = oldCursor; } } } }
RowCount and ColCount are both set at 200 right now.
The second last line must look really strange but I needed it to even get as
far as I did.
Outside of the above, the only other main change I made that I can think of
is right button clicks now rotate image in grid cell 90 deg each click
(counterclockwise)
I notice there never seems to be attachments to the newsgroup posts, but if
you would like Remy I would be very happy to zip everything up and send it
to you (directly?) if it might appear there is something else I have not
mentioned causing the difficulty.
Sure appreciate all this effort on my behalf very very much.
Richard