|
Hi,
In my SDI application in a FormView I use two dialogs (multi-form application) one of them is dynamically selected at runtime.
So, I can't add any variables of the controls on the second dialog to my view class because it gives error at runtime as it can't associate that variable with the first dialog, because of the way the variables are defined, like as follows:
public:
//{{AFX_DATA(CFormTestView)
enum { IDD = IDD_DIALOG1 };
CEdit m_EditCtrl;
//}}AFX_DATA
Now my problem is: in the second dialog I have a list control and I want track dbl-click and rt-click messages from that control. So, I have a class CMyListCtrl which is subclassed from CListCtrl. As I can't have a variable of my List Control, how can I associate the List Control to CMyListCtrl so that I can handle the different Events?
Please advise
|
|
|
|
|
I don't want to change my design and make multiple views. Please help me on this:
I can't have a variable of a List Control (I know the resource ID), I want it to be an object of CMyListCtrl which is a class derived from CListCtrl.
Now, I have written handlers like the following:
void CMyListCtrl::OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = TRUE;
}
How do I associate my Control to CMyListCtrl, so that these handlers are invoked? Please help, I'm stuck here
Thanks
|
|
|
|
|
<b)hi
i="" want="" to="" reproduce="" a="" wm_keydown="" manualy.
how="" can="" i="" do="" that.<="" b="">
|
|
|
|
|
Look at PostMessage().
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Hi All!
I need to handle a pressing keyboard event(hot key)when my application is inactive and let the current active application to handle it too.
How can I do that?
|
|
|
|
|
look at Win32 Hooks ... WH_KEYBOARD .. SetWindowsHookEx
you can capture any type of user command (at any time)
|
|
|
|
|
Thanks a lot for your help.
Could you please introduce me a good sample cod for that.
Best Regards,
Minoo
|
|
|
|
|
http://support.microsoft.com/default.aspx?scid=kb;en-us;66989
|
|
|
|
|
Probably you guys already know that but in case someone does not...
As we all know, while Win9x can only display the old-school "File Open/Save/Save As" dialogs, Win2000/XP are capable of displaying new style ones, of which there are 5 buttons located on the left side pane:
"History", "Desktop", "My Documents", "My Computer" and "My Network Places"
This new style CFileDialog not only looks nicer, but also provides much more convenience to the users, so why don't we all use it if the user's OS is Win2000 or WinXP? Well, the answer is how.
MFC does not seem to offer a way to display the new style CFileDialog , it always displays the old style regardless of the flags we specify, is that true? No.
In fact, MFC can display the new style, but for some reason it did not explicitly tell us how to, or maybe it did somewhere but who the hell could find the hints... Anyway, after some deep digging I finally found out that, it prbably will disappoint you, all we need to do is to add one single line of code into our project and voila! We have it ---- the pretty nice beautiful neat sexy new style dialog. Here is the code:
CFileDialog dlg(TRUE);
if (::GetVersion() < 0x80000000) dlg.m_ofn.lStructSize = 88;
dlg.DoModal();
So is that simple?
----------------------------------------
I saw a man saw a saw with a saw.
|
|
|
|
|
There are different versions of the OPENFILESTRUCT in different OSes. Changing that member is not safe - you're changing the "size of struct" value, but you don't actually have a larger struct like you're claiming to have. Good luck, hope it doesn't crash on your customers' systems.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Ericahist updated (again) Sep 6!
|
|
|
|
|
First of all, I must apologize for the lack of detailed explanation in my original post,it was not an article but some little piece of information so I was trying to keep things as simple as possible, but as a result it may confuse or mislead the readers due to the over-simplicity.
So, while having a good point on "safety emphasis", Dear Michael Dunn, your comments were not entirely correct, here's why.
When we use a CFileDialog , an important step is to initialize its member data m_ofn , which is a instance of OPENFILENAME struct, whose definition is as below:
typedef struct tagOFN {
DWORD lStructSize;
DWORD Flags;
#if (_WIN32_WINNT >= 0x0500)
void * pvReserved;
DWORD dwReserved;
DWORD FlagsEx;
#endif // (_WIN32_WINNT >= 0x0500)
} OPENFILENAME, *LPOPENFILENAME;
The Flags is where we specify dialog styles and lStructSize is where we specify the struct instance size. The total size of data member before #if (_WIN32_WINNT >= 0x0500) is 76 bytes, of data reserved for Win2000/XP is 12 bytes (4 bytes* 3), so total size of each instance of OPENFILENAME is 88 bytes in Win2000/XP, and 76 bytes otherwise.
In my original post, before I actually changing the m_ofn size, I did carefully verify the OS version using ::GetVersion , I change the size to 88 if and only if the OS is Win2000/XP, so I don't see why my code would crash my customer's system.
|
|
|
|
|
(I'm assuming we're talking about MFC 6 here, btw)
No, when you create a CFileDialog variable, it contains an OPENFILENAME member. The size of this struct does not change because the code to create it is compiled into the MFC LIB or DLL. The value of lStructSize that you read is exactly the size of the contained struct. Changing your _WIN32_WINNT define doesn't recompile the MFC code, so it has no effect on that member.
So now look at what you have, m_ofn is a struct whose real, actual size is X bytes. You reset lStructSize to X+12 bytes, which is you saying that the struct is now 12 bytes larger and the data in those 12 bytes is usable. However, you have not changed the size of the struct in memory. The OS will go ahead and treat the struct as if it were larger, since it assumes you set lStructSize right. Who knows what is in those 12 bytes... you never initialized them (and you can't, because the struct isn't that big) so the result will be unpredictable.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Ericahist updated (again) Sep 6!
|
|
|
|
|
Thanks for your comments and criticism, now I got one question, how do we show the new dialog style without setting lStructSize to 88?
|
|
|
|
|
It's too bad that your post will get buried in the bowels of history because this is a neat little tidbit of information. Even though it is only a little code snippet, maybe you could consider an article? Then this info will be easier to find when someone needs it.
CP really needs a code snippets section.
[edit]after reading Mike Dunn's post, I think he is right, but there must be a way to get it to work. Maybe deriving a class from CFileDialog, and substituting your own OPENFILENAME struct depending on the OS.[/edit]
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Hi,
In my SDI application I have a ListBox (NOT a ListControl) in one of the dialogs. I want to make this ListBox editable depending on the selection from a contextmenu. How do I make my ListBox editable?
Please help
|
|
|
|
|
From memory there is no in-place editing capabilities in ListBox. You could create an edit control and position it over the list item. You should find code here on CP to do that. Or switch to using a CListCtrl.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
How do I have editable CListCtrl. Please let me know. I just need one column in the ListControl. I have set the style editable, but, I can't edit anything.
|
|
|
|
|
I have a list box with several items and a button which will pop out a dialog when clicked. I used this same dialog for all the items.But I have this problem: if i update the data in the dialog for a particular item, the OnOK button in dialog will update it but once i select another item, the data will b that of the prev item. Also, i expect to retreive the same data if i select back the same item. Is there a way to keep updates for each item separate other than creating a dialog for each item? that will b tedious..thanx
|
|
|
|
|
Use the loopback address.
127.0.0.1 or "localhost"
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
now i have only one problem with ip addresses. I have my internet domain name and my internet ip address, but none of them work from here. What am i supposed to use if i want to access the computer from outside my network?
-- Steve
|
|
|
|
|
I am making a project for school that is a game of tic-tac-toe. It is the console c++ not visual although I could do that but first I need one in console. See I need to make it work somehow and I was thinking of making an
if(user_inputbox1)<br />
...<br />
if(user_inputbox2)<br />
...
but for now I just have...
#include <iostream><br />
#include <cstdlib><br />
using namespace std;<br />
<br />
char matrix [3] [3];
<br />
char check();<br />
void init_matrix();<br />
void get_player_move();<br />
void get_computer_move();<br />
void disp_matrix();<br />
<br />
int main()<br />
{<br />
char done = ' ';<br />
<br />
init_matrix();<br />
<br />
do{<br />
disp_matrix();<br />
get_player_move();<br />
done = check();
if(done != ' ') break;
get_computer_move();<br />
done = check();
} while(done == ' ');<br />
<br />
if(done=='X') <br />
cout << "You won!\n";<br />
else<br />
cout << "I won!!!!\n";<br />
<br />
disp_matrix();
<br />
return 0;<br />
}<br />
<br />
void init_matrix()<br />
{<br />
int i, j;<br />
<br />
for(i=0; i<3; i++)<br />
for(j=0; j<3; j++) matrix[i][j] = ' ';<br />
}<br />
<br />
void get_player_move()<br />
{<br />
int x, y;<br />
<br />
cout << "Enter X,Y coordinates for your move: ";<br />
cin >> x;<br />
cin >> y;<br />
<br />
x--; y--;<br />
<br />
if(matrix[x][y]!= ' '){<br />
cout << "Invalid move, try again.\n";<br />
get_player_move();<br />
}<br />
else matrix[x][y] = 'X';<br />
}<br />
<br />
void get_computer_move()<br />
{<br />
int i, j;<br />
<br />
f: i = rand() % 3;<br />
j = rand() % 3;<br />
<br />
if(matrix[i][j] !=' ')<br />
goto f;<br />
<br />
if(i*j==9) {<br />
cout << "draw\n";<br />
system("pause");<br />
}<br />
else<br />
matrix[i][j] = 'O';<br />
<br />
<br />
<br />
}<br />
<br />
void disp_matrix()<br />
{<br />
int t;<br />
<br />
for(t=0; t<3; t++) {<br />
cout << matrix[t][0] << " | " << matrix[t][1] << " | " << matrix[t][2];<br />
if(t != 2) <br />
cout << "\n---|---|---\n";<br />
}<br />
cout << "\n";<br />
}<br />
<br />
char check()<br />
{<br />
int i;<br />
<br />
for(i=0; i<3; i++) <br />
if(matrix[i][0]==matrix[i][1] && matrix[i][0]==matrix[i][2]) <br />
return matrix[i][0];<br />
<br />
for(i=0; i<3; i++) <br />
if(matrix[0][i]==matrix[1][i] && matrix[0][i]==matrix[2][i]) <br />
return matrix[0][i];<br />
<br />
if(matrix[0][0]==matrix[1][1] && matrix[1][1]==matrix[2][2])<br />
return matrix[0][0];<br />
<br />
if(matrix[0][2]==matrix[1][1] && matrix[1][1]==matrix[2][0])<br />
return matrix[0][2];<br />
<br />
return ' ';<br />
}
Please make suggestions, comments, even brutal statements to make this a working, awesome app.. since the rand() is way off the computer move cause I just put it there to make it look how the comp would act.
MAINLY TRYING TO SOLVE THE GET_COMP METHOD TO MAKE THE COMP IF NOT UNDEFEATED THEN AT LEAST MAKE A DRAW...
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Well, to make the computer act like a person playing tick-tac-toe, have it select the center square first if possible. Second, to do vertical and horizontal rows, have the computer run a check of the vertical and horizontal rows, find one that is empty, and try to complete a row by using the same number for one of the array dimentions. I hope that helps.
-- Steve
|
|
|
|
|
Please could someone explain to me the difference between sock4 sock4a and socks5?
Best Wishes,
Marty
|
|
|
|
|
|
I have been wondering what is the best way to handle large scale projects and headers.
Currently for the VCF I have followed a 1 class = 1 header policy. For the Appkit I have ~ 233 .h files (acording to PLC).
Compiles, even with precompiled headers, take a bit. Is there a better way to organize the class declarations?
Is it smarter (even if it is not as easy to find classes) to *not* use the 1 class per .h rule, and instead combine many classes into one header?
Should common comment blocks (like CVS rev info, and copyright notices) fall before the include guards or within (or does it matter?)? For example:
(a)
#ifndef _FOO_H__
#define _FOO_H__
#endif //_FOO_H__
(b)
#ifndef _FOO_H__
#define _FOO_H__
#endif //_FOO_H__
Which is more efficient (a) or (b)?
I am using a fair amount of templates and some preprocessor stuff to add the extra RTTI support the framework uses. Does this make a big difference in compile times?
Thanks
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|