|
for mouse pos, try with
GetCursorPos(LPPOINT);
or
DWORD pos = GetMessagePos();
CPoint pt(LOWORD(pos), HIWORD(pos));
ScreenToClient(&pt);
KalliMan
|
|
|
|
|
If you want to unsnap you will need to track the direction of the mouse movement. i.e. if it is moving away from the edge then do not apply the snap criteria.
For this you will need to store the last position of the mouse then compare with current position. You can then decide whether to snap or not.
Ant.
|
|
|
|
|
Hi.
I am writing an application where I have a dialog with one combo box and 4 edit controls. Now when I open that dialog there is always first edit control focused. How can change this behaviour so for example rather than the first I would like the third edit control to be automatically focused, so when the user opens the dialog one can start typing into that (third) edit control rather than using a mouse to click on it first.
I thought it would be as simple as that:
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CtrlSourceExt.SetFocus(); // PROBLEM IS HERE - Set foucus to this edit control (this Doesn't work) (NOTE: variable CtrlSourceExt is of type CEdit)
UpdateData();
return TRUE; // return TRUE unless you set the focus to a control
}
Actually I remember in VC++ 6 I could specify the order of things to be focused in resource editor when designing a dialog. So if I had say 4 edit controls I could set focus in this order 4,2,1,3 so the first hightlighed edit control would be 4 then if the user pressed tab once it would take him to edit control 2 then 1 and 3. But now in VC++ 2003 .NET it doesnt work. Same thing with profiler I just cant find it. I dont know why they got rid of such useful thing. Anyway going back to the subject. Can anybody help?
Thanks.
|
|
|
|
|
Perhaps u must set the focus in 'CTestDlg::OnShowWindow()'.
KalliMan
|
|
|
|
|
robert_s wrote:
return TRUE; // return TRUE unless you set the focus to a control
TOXCCT >>> GEII power
|
|
|
|
|
Thanks toxcct ) Returning FALSE fixes the problem
HAHA!!! S*** I haven't noticed these comments generated by a wizard. How embarassing....
Sorry!
But still its a bit silly to me to return FALSE. The function name (OnInitiDialog) suggests that I am initializing a dialog and if successfully initialized it should return TRUE otherwise FALSE if unsuccessful. But here even though the dialog is initialized I am returning FALSE. hehe! I cant see any logic here? Perhaps I still need to learn more the way how MS people think ) hehe..
Thanks all for help!!
|
|
|
|
|
robert_s wrote:
But still its a bit silly to me to return FALSE. The function name (OnInitiDialog) suggests that I am initializing a dialog...
The return value has nothing to with success/failure. It simply denotes whether the application has set the input focus to one of the controls in the dialog box.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
hello,
do you know the name of any book that explain how to program a cd writer I need to know how to burn cds -erase cds etc.
Thanks in advance
|
|
|
|
|
|
I would like to know how create child windows at runtime and get them all displyed
Yes I've used:
- a pointer for the control
- the new operator for the window type
- CWnd::Create method
- CWnd::ShowWindow method
- CWnd::MoveWindow method
All I'm getting is a blank dialog box. I can't understand why.
What do I have to do display them?
|
|
|
|
|
Please show us a little bit of your source code...
|
|
|
|
|
This is a snippets of my code
in the dialog header file
class CMyDialouge : public CDialog{<br />
public CEdit *m_EditWnd;<br />
CRect m_WndRect;<br />
};
The dialog's constructor
CMyDialouge::CMyDialouge(CWnd* pParent )<br />
: CDialog(CMyDialogue::IDD, pParent)<br />
{<br />
m_EditWnd = NULL;<br />
m_Rect = CRect(23,30,54,14);<br />
}<br />
Create 5 versions of the edit control
BOOL CMyDialouge::OnInitDialog()<br />
{<br />
this->m_EditWnd = new CEdit[5];<br />
<br />
for(int i = 0; i < 5; i++)<br />
{<br />
m_EditBox[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i);<br />
m_EditWnd[i].MoveWindow(m_Rect);<br />
m_EditWnd[i].ShowWindow(SW_SHOW);<br />
<br />
m_Rect.top += 30;<br />
}<br />
return TRUE;
<br />
}
void CMyDialouge::OnDestroy<br />
{<br />
for (int i=0; i <5; i++)<br />
m_EditWnd[i].DestroyWindow();<br />
<br />
CDialog::OnDestroy();<br />
<br />
delete[] m_EditWnd;<br />
}<br />
I hope I've clarified it.
Thanks Alton
|
|
|
|
|
In CMyDialouge::OnInitDialog() you wrote
m_EditBox[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i);
m_EditWnd[i].MoveWindow(m
You used m_EditBox AND m_EditWnd, may it be that this is your mistake?
Jens
|
|
|
|
|
Jens Doose wrote:
m_EditBox[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i);
Correct to (compiler will complain):
m_EditWnd[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i);
|
|
|
|
|
You used CRect(23,30,54,14); as the location to move the window to.
This statement create a rect with the following settings:
- m_Rect {top=30 bottom=14 left=23 right=54}
- tagRECT {top=30 bottom=14 left=23 right=54}
left 23
top 30
right 54
bottom 14
Since "bottom" is less than "top" this is a rect with a negativ height.
I am pretty sure that was not your intention, was it?
Jens
|
|
|
|
|
Most of the time, creating controls at runtime is not necessary. Can you explain a bit more of what you are doing?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I just wanted to play around with dynamic controls
I've given code snippets in the reply before yours.
Thanks Alton
|
|
|
|
|
Yes, I understand!! I'm trying to create a MenuBar at runtime but all itens in the menu is GRAYED (disabled) when created!!! I don't know why?!?!?
Maybe some help in your doubt helps in mine!!!
Thanks
Marcos Vinícius
|
|
|
|
|
If your using MFC one of the more common mistakes is that there is no command handler yet. In that case MFC grayes all the unavailable menu commands.
Jens
|
|
|
|
|
But, why is it unavailable? I can't just put a Message_Map in my class that handle the App MenuBar and that will enable the MenuItens?
Take a look in my last thread posted:
Menu at runtime (dynamic menu)
Thanks.
Marcos Vinícius
|
|
|
|
|
okay here it goes ...
my app crashes cause of a DLL (coded correctly)
my DLL is accessing to a file, only to read ...
isn't it allowed to a dll to read a file? how to fix it ?
is there maybe another error?
Its a simply Win32 dll with CPP, Header and Def file
and my app is a console app (MFC apps crash too)
the debugger links me to "output.c"
if i write other console apps it crashes too ...
can any1 help me?
int main(int argc, char* argv[])<br />
{<br />
if (argc < 2)<br />
{<br />
printf ("Usage is: <CharFile> \n");<br />
getchar();<br />
return 1;<br />
}<br />
char * output = "";<br />
char hash[5] = "abcd";
char * outputfile = "";<br />
sprintf(outputfile,"%s.txt",argv[1]);<br />
FILE * fp = fopen(argv[1],"r");<br />
FILE * f = fopen(outputfile,"wt");<br />
<br />
if (!fp)<br />
{<br />
printf ("Error opening file %s\n", argv[1]);<br />
getchar();<br />
return 2;<br />
}<br />
int findex = 0;<br />
unsigned char d;<br />
while (!feof(fp)) <br />
{<br />
int c = fgetc(fp);<br />
if (c == EOF) break;<br />
unsigned char k = (hash[findex % 4] + findex) % 256;<br />
d = c ^ (k | 0x80);<br />
findex++;<br />
output += (char) d;<br />
fprintf(f,(const char *) d);<br />
}<br />
fclose(fp); <br />
fclose(f);<br />
return 0;<br />
}
|
|
|
|
|
How can I move the caret in an CEdit control forward or backward in characters, not in coordinates?
SmileAgain
|
|
|
|
|
Perhaps CEdit::SetSel (nCharPos, nCharPos, TRUE) ?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi,
I want to create the following splitters.
1. ParentSplitter - 2 cols and 1 row (vertical split)
- derives from CFrameWnd-SDI based
- 1st pane has a class derived from CTreeView (so this will be SDI-based)
- 2nd pane should be ChildSplitter
2. ChildSplitter - 2 rows and 1 col (horizontal split)
- derives from CMDIChildWnd-MDI based
- 1st pane and 2nd pane will derive from CFormView
So basically I want the parent to be SDI-based as its 1st pane (the TreeView) is SDI-based but its 2nd pane needs to be a MDI-based splitter. this application should look more or less like visual studio 6 having a tree on the left pane and double-clicking on a file should open a new window on the right pane ...
Can this be done? .. or is there any work-around for this concept .. If so can anyone plz guide me ...
thanks a lot
|
|
|
|
|
I faked this by creating a standard MDI app, using a docking window for the tree view. My "tree view" is actually a dialog template that houses a tab control, which displays various views (tree, list) of the open "project". It seems you're trying to do the same thing.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|