|
sorry but...
you're fully wrong !
i need to change the default button programmatically because the default button will change in time depending on several events...
you've got it now ?
TOXCCT >>> GEII power
|
|
|
|
|
Use resource eidt ,set the button default.
|
|
|
|
|
ok, and when i want to change the default property when the program is running, what do i do ?
TOXCCT >>> GEII power
|
|
|
|
|
how can i check if, when i have an entiere path, if the file already exist, and to use it ONLY if the file exist ?
thx for answers...
TOXCCT >>> GEII power
|
|
|
|
|
GetFileAttributes() check for return of (DWORD)-1
or else
_taccess(<filepath>, 00);
There are others, I use the first one.
|
|
|
|
|
BOOL FileExists( const char* pszPath );
There is no spoon.
suhredayan
|
|
|
|
|
What Happen to Great TOXCCT,Long Time NO SEE
any way Simple Api is
BOOL PathFileExists(<br />
LPCTSTR pszPath<br />
);
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
hum, well, could not connect until now... for a short week...
anyway, very thanks to you Mist'Alok
see you
TOXCCT >>> GEII power
|
|
|
|
|
Hi ,
I have a SDI application in which my DOC type is of .xml.
I want to override the standard serialize mechanism to load and Save data but need a handle to the current file (say newDoc1.xml )from within the Doc class as I am externally going to load and save the data using an XML parser object (member of Doc class) . How do I get access to the fileName ?
Thanks
|
|
|
|
|
act_x wrote:
How do I get access to the fileName ?
Use CDocument::GetPathName() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi all
i dared to code a simple 3d viewer with my limited iq. i want to get 2 panes with a vertical static splitter. The left will have a Tree control and right (CMgcCanvas) will draw the model. canvas is derived from CView and OnCreate is overrided. Splitter and tree works well. I added a Messagebox to OnNotify() of CMgcCanvas and CEditorView.
Problem: When i click left pane i can see my messagebox but at right it doesnt work! why?
Note : when i create the tree at right pane, left pane doesnt show messagebox.
Do i create CMgcCanvas wrong?
Thanks In Advance,
Burak
At OnCreateClient proc. of mainframe i did it as ;
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
//calculate client size
CRect cr;
GetClientRect( &cr);
//Create Splitter
if ( !m_mainSplitter.CreateStatic( this, 1, 2 ) )
{
MessageBox( "Error setting up splitter frames!",
"Init Error!", MB_OK | MB_ICONERROR );
return false;
}
//Create pane views of splitter
//Editor - Tree View
if ( !m_mainSplitter.CreateView( 0, 0,
RUNTIME_CLASS(CMGCEditorView),
CSize(cr.Width()/3, cr.Height()), pContext ) )
{
MessageBox( "Error setting up splitter frames!",
"Init Error!", MB_OK | MB_ICONERROR );
return false;
}
//Canvas View
CRuntimeClass* canvas = RUNTIME_CLASS(CMgcCanvas);
if ( !m_mainSplitter.CreateView( 0, 1,
canvas, CSize(cr.Width()*2/3, cr.Height()), pContext ) )
{
MessageBox( "Error setting up splitter frames!",
"Init Error!", MB_OK | MB_ICONERROR );
return false;
}
m_bInitSplitter = TRUE;
CRect leftrect, rightrect;
m_leftpane = m_mainSplitter.GetPane(0,0);
m_rightpane = m_mainSplitter.GetPane(0,1);
m_leftpane->GetClientRect(&leftrect);
m_rightpane->GetClientRect(&rightrect);
//Create Tree Control
m_MgcTree = new CMgcTree;
if (!m_MgcTree->Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD |
TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
CRect(0, 0, leftrect.Width(), leftrect.Height()),
m_leftpane, IDC_TREE1))
{
TRACE0("Failed to create instant bar child\n");
return -1; // fail to create
}
m_MgcTree->Initialise();
//Create Canvas View -???
m_canvas = new CMgcCanvas;
if (!m_canvas->Create(NULL,"Canvas",WS_VISIBLE | WS_TABSTOP | WS_CHILD ,
CRect(0, 0, rightrect.Width(), rightrect.Height()),
m_rightpane, 143))
{
TRACE0("Failed to create canvas\n");
return -1; // fail to create
}
return true;
}
|
|
|
|
|
I had a similar problem with a control that I derived from CStatic for displaying 3D Models (See 'My Articles' below, "A beginning DirectX Application using MFC"). The problem was that I didn't have the 'NOTIFY' style set for the class, so it wasn't receiving any messages. I don't know if that's your problem, but maybe look into that.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
well i found the answer.
Microsoft says ;
The framework calls this member function to inform the parent window of a control that an event has occurred in the control or that the control requires some kind of information.
Tree sended the message as a control but i didnt have any at the view pane.
CMgcCanvas::OnLButtonDown works well.
it didnt help but great code .. thanks BlackDice
i'll send my code first to you if it gets out of stupid class!
|
|
|
|
|
Hi !
I have a program that saves some data to a file. The data is saved in binary. To make simple (things are a little bit more complicated in my program): I have a structure with some members in it (just regular members, no pointers). To save it, I use fwrite providing the size of the structure (with sizeof(MyStruct)). Of course, several of these objects are saved.
Now, I need to add some new members in my structure, and of course, the files won't be compatible. So I want to have a mechanism that when I need to add new members, things will be compatible without creating the file again.
I was thinking of putting, at the begining of the file, the data size of the structure in the file. Then, when loading data, I make a fread with this size. So, when I add new members to my structure (of, course, I need to add them at the end of the struct), I will read only the data that were saved.
What do you think ? Is there a better suggestion or... ?
Thanks
|
|
|
|
|
Given what you have aleady, that will work. However, how important is it to save all your data in binary? Have you considered a more flexible format, such as XML? Or even just ini-style files (Name=Value pairs inside of [Keys]?)
Somebody will mention MFC serialization. That can work, and it does have versioning abilities, but I'd be careful... if your structures/classes change too much, you could have the same problem you have now.
An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
|
|
|
|
|
In fact I was first thinking about ini files but this will be too much complicated and far too less secured (I don't want anybody to change parameters inside). Everything must be configurated inside the program.
Serialization, not because I want to have more access to what I'm doing and I'm not really saving 'pure data'. What I'm saving is configurations (but very complicated configurations ).
|
|
|
|
|
The idea you have is good, or else you can create a keyed file...
[object size][object type][object data]
Your file ends up looking like this sequence of data:
<dword><dword><datastructure><dword><dword><datastructure>
This allow you to add different structures into your file and to skip those you do not recognize.
Of course, you can not randomly seek into your file any more if you do this.
|
|
|
|
|
I've seen many ways to do this, not all are compatable. Some that I've seen:
Best: don't write out structs. Write XML or some other text format that is [partially] human readable.
Each struct starts with two fields, majic and version. magic is a number (often someone's birthday), choosen so that no two structers magics will ever be reused. Math people sometimes statisticly find some bit pattern that is unlikley to be hit randomly, so they can detect file corruption and the like.
#define MYSTRUCT_MAGIC 0x19540331 // mom's birthday
struct mystuct {
LONG magic;
LONG verion;
... // all data
}
When loading you check magic and version. If they are recognized you load, if the version is old you may reorginize things, and such.
It is a good idea to start your files with a simple string that says what recorded it.
save(struct myDataList *data) {
fd = open(...);
write(fd,"myApp Version 1.x",16);
... // write all the structs out here
}
I don't really like your idea. It doesn't deal with the case where you delete a member, or change the meaning of a member.
|
|
|
|
|
Henry miller wrote:
It is a good idea to start your files with a simple string that says what recorded it.
Yes I already thought about that (I will add this for future modifications ).
Henry miller wrote:
I don't really like your idea. It doesn't deal with the case where you delete a member, or change the meaning of a member.
Here this is not a problem because I won't delete any members. Everything will go in the other direction: add member but never delete or change existing memebers.
|
|
|
|
|
Yeah, thats what they all say. Then someday in the future someone does so anyway. It always happens that the things you least expect to happen are the ones that happen first.
Of course if this is a personal project that isn't much an issue. If this is any bigger though you have to expect that someone else will do something to your code without understanding why you didn't. They will notice that you always write a zero someplace, and never do anything with it so they remove it. And it works until someone trys to load data saved 3 versions ago which had the same size...
|
|
|
|
|
Ok, thanks to everybody for your advices. There are some good suggestions. And also that gave me good ideas for new projects (like saving in XML format)
|
|
|
|
|
i'm using visual c++ .net 2003 and already have some previous code which puts data into a UCHAR variable (dataBuffer[512]). then, what i want to do is pick out certain bytes and display them in a textbox. i'm able to take the bytes and display them to a textbox by using the ToString() method but the problem is that instead of the letter A, the number 65 is printed (instead of the character the ascii code is printed). need help on this...
|
|
|
|
|
I'm not sure, but how about using ToCharArray() instead? or putting the bytes in a 'string' first, then using ToCharArray()?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
my code goes a little something like this
UCHAR dataBuffer[512];
.
. //processes stuff and puts
. //data inside dataBuffer.
.
for (a=0;a<4;a++)
{
display->AppendText(dataBuffer[a].ToString());
}
. //display is the name of my textBox.
.
.
|
|
|
|
|
I'm using FindWindow(),(just testing some stuff), and it doesn't seem to work for some of the windows I'm trying to get pointers to. For instance, this doesn't seem to work:
CWnd* pButton = this->FindWindow("Button","start");
if(pButton)
{
pButton->SetWindowText("Finish");
AfxMessageBox("found window");
}
but it works for me changing the caption of "Visual FoxPro" to "Visual CrapPro". (I HATE FoxPro).
Does anyone know what I'm doing wrong?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|