|
No, because the pointers points to two different locations. Except if you do something like that:
char* point = &buffer[0];
But then of course, you don't need to use strcpy anymore. strcpy just copy bytes from one memory location to another, it is similar as memcpy (except that it works for null-terminated strings).
|
|
|
|
|
|
Programm3r wrote: If the value of the point changes there after, will the value of the buffer change too??
Why don't you try it and see?
"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 MFC application I've create two buttons, OPEN and CLOSE, used to open a text file and close it. I do it as follows.
<br />
void CSRFToolDlg::OnBnClickedOpen()<br />
{<br />
char* ReadFileName = "G:\\Work On\\CPP\\SRFTool\\text_file.txt" ; <br />
<br />
if(openFile.Open(ReadFileName, CFile::modeCreate | CFile::modeReadWrite))<br />
{<br />
AfxMessageBox("File creates successfully", MB_OK) ;<br />
}<br />
else<br />
{<br />
AfxMessageBox("Error in file opening", MB_OK) ;<br />
}<br />
}<br />
<br />
<br />
void CSRFToolDlg::OnBnClickedClose()<br />
{<br />
openFile.Close() ;<br />
}<br />
What I want to do is, until user click the Open button the Close button should be disable. How should I do it. Those stuff really new for me.
Thanks
-- modified at 6:08 Thursday 11th October, 2007
I appreciate your help all the time...
|
|
|
|
|
Stablish a control member variable to the with the class assistant (ctrl + w, second propertie page) or
use CWindow::GetDlgControl (nID) in order to have access.
Then use EnableWindow (TRUE); //or false as you want
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Can you explain it with my code. What you mean second property page. I'm unable to found that.
I appreciate your help all the time...
|
|
|
|
|
hi,
Try this one...
Disable the button in OnInitDialog of your dialog class
eg:
GetDlgItem(UR_CLOSE_BUTTON_ID)->EnableWindow(FALSE);
Enable that button in OnBnClickedOpen function
void CSRFToolDlg::OnBnClickedOpen()
{
char* ReadFileName = "G:\\Work On\\CPP\\SRFTool\\text_file.txt" ;
if(openFile.Open(ReadFileName, CFile::modeCreate | CFile::modeReadWrite))
{
AfxMessageBox("File creates successfully", MB_OK) ;
GetDlgItem(UR_CLOSE_BUTTON_ID)->EnableWindow(TRUE);
}
else
{
AfxMessageBox("Error in file opening", MB_OK) ;
}
}
Again Disable the button in OnBtnClickedClose()
void CSRFToolDlg::OnBnClickedClose()
{
openFile.Close() ;
GetDlgItem(UR_CLOSE_BUTTON_ID)->EnableWindow(FALSE);
}
If you the control variable of Close button, the user that variable in place of GetDlgItem(UR_CLOSE_BUTTON_ID)
|
|
|
|
|
Lakshmi_p wrote: If you the control variable of Close button, the user that variable in place of GetDlgItem(UR_CLOSE_BUTTON_ID)
Do you mean that the ID of the control(button ID). I'll do it in that way, it's disable after clicking the Open button.
If I can load
GetDlgItem(UR_CLOSE_BUTTON_ID)->EnableWindow(FALSE);
in form load, it will work. How to access to the form load.
I appreciate your help all the time...
|
|
|
|
|
form load function you can find it in visual basic.
but in vc++6.0, the analogous function is init dialog.
you can write the code as suggested by lakshmi there.
and also in the buttons.
any more doubts?
get back.
|
|
|
|
|
Actually I found a way to do it. Just define in OnInitDialog(). It works. What you think about that.
I appreciate your help all the time...
|
|
|
|
|
congradulations!
|
|
|
|
|
Thanks. Seems to me lots of things can be done there, like global initializations and stuff. I want to try them later.
I appreciate your help all the time...
|
|
|
|
|
mmm, ok, let see...
You stablish your form or your dialog in the resource editor, then you drag a button from the toolbar and drop it on your form. If you select the button and press enter, you get a properties window where as default comes IDC_BUTTON1 this is the ID of the button (you may always change it to you names, i.e. IDC_BUTTON_OPEN), you have the caption and so on...
once you have the buttons with the correct names, you can press CTRL + W and comes the class wizard assistant. When it opens you have the "Message order table" property sheet opened, the second is "Member variables", the third "Automation" and so on...
In the second one "Member variables" you will have a list with all the IDs of the form, in this case the two buttons, click on add variable and complete the "m_ " field with a name to reference the button in your code.
Create the second button and uncheck the property "Enabled" in the properties window of the button (at the bottom)
If you do it in that way, you can always use this name directly to access or modify the button.
You will have something like that in your CDialog.cpp
void CMyView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BUTTON_OPEN, m_cbOpen);
DDX_Control(pDX, IDC_BUTTON_CLOSE, m_cbClose);
}
one that is done...
you can use another time the class assistant (this time in the first sheet "Messages Table") to look for the name of your button in the left listbox and include a function of the right listbox. In this case your OnButtonOpenClick
void CMyView::OnButtonOpenClick()
{
m_cbClose.EnableWindow (TRUE);
}
and to reset the enable
void CMyView::OnButtonCloseClick()
{
m_cbClose.EnableWindow (FALSE);
}
The other way to make it is without using member variables, taking a pointer to the control using the ID and the GetDlgControl () function as the other answer already explains.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Thank you for the long explanation. I learn a lot from there. Meantime I found one way to do it. As I asked earlier, I'm looking to find where the form load or any smiler operation is going on.
OnInitDialog() behave like that. I placed the code
GetDlgItem(IDC_CLOSE)->EnableWindow(FALSE) ;
for Close button it works. What's your comments.
Thanks
I appreciate your help all the time...
|
|
|
|
|
if it works... it works.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Ya, seems to me it is correct. But haven't found that it is used on the web, not on the MSDN as well. Anyway it works as form load in Visual Studio .Net 2003
I appreciate your help all the time...
|
|
|
|
|
use of m_Open.EnableWindow(1); or 0 for disable
|
|
|
|
|
I created an MFC ActiveX Control with VC++ Wizard. Compiled it without changing anything. Created a webpage, put it in (it draws an ellipse).Now drag the horz scrollbar, the image inside the activeX control is teared and dragged terribly. It even draws the border on the surface of activeX control. how to avoid this flickering.
|
|
|
|
|
can you explain more,
because, i used my own active X controls, which display images in web pages(html). but i never faced such problem.
|
|
|
|
|
Hi,
Is it possible to make the client area of a window as non-rectangular? If yes how?
Thanks in advance.
- NS -
|
|
|
|
|
Yes, i have a word document where it is explained how to make a round window, the most important problem... It is on spanish. But if you want I can send you it, and take a look in the code that is being explained (altough you can not understand the explanations)
if rounded is possible, I guess polygonal will be possible too.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Thank you for the replay. But are you sure that it says about creating the client area as round? Or simply the window?
Anyway I dont know Spanish But if you kindly send it I may try by using any translators
- NS -
|
|
|
|
|
Now that you say it... it is a round window (I read it too quick). So it problably won't be usefull at all.
But... it is a bit difficult to see the concept, if the window is not round... why to stablish a round client area?
and an innocent try...
have you thought about masking the squared client area with a user defined region and avoiding all what is outside the limits of the region?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Let me say an example. Suppose my window has a round shape. And it has child controls. And my requirement is that, the border should be of a few pixels. So the childs should be clipped by the round client border if it is placed beyond the client. If only rectangular shape is possible for client, you can imagine what will be the problem. There will be non uniform border thickness, right?
- NS -
|
|
|
|
|
Send me a pm to have your email and I will send you the document anyways, there may be some code that gives you an idea.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|