|
Do it!
Good luck!
|
|
|
|
|
You could start from
#include <stdio.h>
int main()
{
int i;
for (;;)
{
printf("please enter a positive integer\n");
if ( scanf("%d", &i) == 1 && i > 0 ) break;
}
printf("you entered %d, a good one\n", i);
return 0;
}
and then find a better way...
|
|
|
|
|
How can I access controls of one class from another class.
Example, Initially the button is hidden. I tried to make it visible from another class by doing like this
GetDlgItem(IDC_BUTTON)->ShowWindow(TRUE); inside a function.
But this doesn't seem to work. How can I make it visible from another class.
Thanks in advance.
|
|
|
|
|
Member 14575556 wrote: But this doesn't seem to work.
What exactly "doesn't seem to work"?
Could you show your code?
|
|
|
|
|
There are two button in Dialog 1.
BOOL CMyFirstDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
GetDlgItem(IDC_BUTTON)->ShowWindow(FALSE);
ShowWindow(SW_MINIMIZE);
return TRUE;
}
When I click one button i want to make the other button visible again.
void CMyFirstDlg::OnBnClickedButton()
{
CSecondDlg* Obj = new CSecondDlg();
Obj->DisplayButton();
}
Inside the DisplayButton function which is in another class there is
GetDlgItem(IDC_BUTTON)->ShowWindow(TRUE);
|
|
|
|
|
Member 14575556 wrote: When I click one button i want to make the other button visible again.
void CMyFirstDlg::OnBnClickedButton()
{
CSecondDlg* Obj = new CSecondDlg();
Obj->DisplayButton();
}
You created the object of CSecondDlg class but you have not created the window of this dialog!
|
|
|
|
|
Member 14575556 wrote: CSecondDlg* Obj = new CSecondDlg();
Obj->DisplayButton(); See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Member 14575556 wrote: How can I access controls of one class from another class. Your question should probably be something like, "How can I access controls on one dialog from a separate dialog?" While it is not a good idea to do so directly (see "loose coupling"), a better way would be to send a message to the parent (the one that owns the control) dialog.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thank you for the pointing me to the right direction.
I'll read about "loose coupling" and to be honest I don't really get how to send message as of now, so I'll read about that too.
I've solve my problem in a naive way for now but i'll definitely follow your suggestions.
Thanks again.
|
|
|
|
|
I have created a simple dialog application where it can perform crud operations but how I did it was I open a connection an do some operations inside most of the buttons as I'm still starting out as a beginner(noob).
What will be a good approach to separate all the database related operations in another class? or keeping as it is, is it a good practice?
I would like some suggestions.
Thank you.
|
|
|
|
|
Since you're asking the question, you probably already know the answer.
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
I did something similar here. It may not be exactly what you are after, but it does give you another perspective, which could ultimately get you to your goal.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
we want to decrease right of non client area in edit control and draw edge in that but wparam in nccalcsize return 1 only not 0 and lparam no give us rgrc0 or rgrc1 value to change it , if somebody try this please tell me its way and show the pictures to do like this
|
|
|
|
|
Please edit your question and show the code you are using, and explain what happens when you run it.
|
|
|
|
|
case win.WM_NCCALCSIZE:
if wParam > 0
{ params := (*win.NCCALCSIZE_PARAMS)(unsafe.Pointer(lParam))
params.Rgrc[0].Top=params.Rgrc[2].Top params.Rgrc[0].Left = params.Rgrc[0].Left + 1
params.Rgrc[0].Bottom=params.Rgrc[0].Bottom-1
params.Rgrc[0].Right=params.Rgrc[0].Right-10
|
|
|
|
|
And where do you handle this message?
Member 11803607 wrote: if wParam > 0
{ params := (*win.NCCALCSIZE_PARAMS)(unsafe.Pointer(lParam))
What does this Quote: := mean?
|
|
|
|
|
wm_nccalcsize Sent when use swp_framechanged in SetWindowPos ( Draw New Style )
i want to decrease the right of client rect to use drawEge in that space was made
|
|
|
|
|
We already know from OP what you want to decrease...
However, we don't know how you are doing it. Richard MacCutchan asked you to post the code related to your problem, but you only have posted some irrelevant lines of your code.
So sorry!
|
|
|
|
|
You imagine a window has Edit control i have to draw rectanle or Edge inside non client area of Edit Control so i have to decrease the width of clint area of edit i think and draw rectangle or Button Shape ( with drawedge api ) between windowrect.right and clientrect.right
|
|
|
|
|
Sorry! i cannot imagine what you meant without seeing the code you implemented for this action!
|
|
|
|
|
how you Draw button inside edit control (t1he right side) ?
to do this i have to make some space in non client area , not client area if button draw in client area when user enter char in edit control , that area ( right side of edit control ) disappear and when move cursor outside again appears
|
|
|
|
|
Member 11803607 wrote: how you Draw button inside edit control (t1he right side) ?
I don't. I never needed it to do myself.
Member 11803607 wrote: to do this i have to make some space in non client area not client area if button shape draw in client area when enter char in edit control that area was drawn button disappear and when move cursor outside again appears
What exactly are you going to achieve? What kind of "button" are you trying to insert inside an edit control and what for?
|
|
|
|
|
i think i asked my question in wrong forum , if somebody work with api fubction maybe can help me .
|
|
|
|
|
Member 11803607 wrote: i think i asked my question in wrong forum , if somebody work with api fubction maybe can help me .
Then, please, rewrite your question much more clear enough to to understand what you want, need, ... and where would be the best place to ask!
|
|
|
|
|
I do not know what that is supposed to be, but that code will not even compile.
|
|
|
|