|
Your english is terrible, I don't understand your problem!
Don't try it, just do it!
|
|
|
|
|
From the "project manager" (PROJECT>SETTINGS>LINK), remove all the unnecessary .lib files from the LINK tab that you dont need in your program. This may help
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Hi
My app is a dialog-based application and I want to know whether there is an elegant way in Visual C++ 6.0 to capture a mouse click event on a specific dialog item. For example, my current application dialog contains two static text elements called, let's say A and B.
I want my application to do something only when portion B (a static text) of the dialog is clicked.
Right now I do it in a seemingly un-elegant way. I first get the rectangle coordinates of the B portion, and when a mouseclick occurs, the main dialog's OnLButtonDown function will compare the click's coordinates with B's coordinates, and it will do something only when the mouseclick occurs inside B.
Is there a more elegant way to do this? E.g., can I instruct B directly to capture mouseclicks?
Thanks!
|
|
|
|
|
Indrawati wrote:
can I instruct B directly to capture mouseclicks?
Yes, just create B with the SS_NOTIFY style. It will the send it's parent window (your dialog) a STN_CLICKED notification message when a user clicks on it.
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,
What additional arguments do I need to pass to this constructor so that when the dialog opens up, I want the dlg to be in default folder (C:\temp)
CFileDialog dlg(true, "txt", "*.txt");
Or any methods of CFileDialog, which I can use to set the default folder?
Presently, the default folder is the desktop.
Thanks
|
|
|
|
|
hi
try
CFileDialog dlg(true, "txt", "*.txt"); <br />
char DefDir[100] = "c:\\abc"; <br />
dlg.m_ofn.lpstrInitialDir = DefDir;<br />
dlg.DoModal();
rgds mil10
|
|
|
|
|
|
OPENFILENAME
The OPENFILENAME structure contains information that the GetOpenFileName and GetSaveFileName functions use to initialize an Open or Save As common dialog box. After the user closes the dialog box, the system returns information about the user's selection in this structure.
typedef struct tagOFN { // ofn
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCTSTR lpstrFilter;
LPTSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPTSTR lpstrFile;
DWORD nMaxFile;
LPTSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCTSTR lpstrInitialDir;
LPCTSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCTSTR lpstrDefExt;
DWORD lCustData;
LPOFNHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
} OPENFILENAME;
Members
lStructSize
Specifies the length, in bytes, of the structure.
hwndOwner
Identifies the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the dialog box has no owner.
hInstance
If the OFN_ENABLETEMPLATEHANDLE flag is set in the Flags member, hInstance is the handle of a memory object containing a dialog box template. If the OFN_ENABLETEMPLATE flag is set, hInstance identifies a module that contains a dialog box template named by the lpTemplateName member. If neither flag is set, this member is ignored.
If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box.
lpstrFilter
Pointer to a buffer containing pairs of null-terminated filter strings. The last string in the buffer must be terminated by two NULL characters.
The first string in each pair is a display string that describes the filter (for example, "Text Files"), and the second string specifies the filter pattern (for example, "*.TXT"). To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.TXT;*.DOC;*.BAK"). A pattern string can be a combination of valid filename characters and the asterisk (*) wildcard character. Do not include spaces in the pattern string.
The system does not change the order of the filters. It displays them in the File Types combo box in the order specified in lpstrFilter.
If lpstrFilter is NULL, the dialog box does not display any filters.
lpstrCustomFilter
Pointer to a static buffer that contains a pair of null-terminated filter strings for preserving the filter pattern chosen by the user. The first string is your display string that describes the custom filter, and the second string is the filter pattern selected by the user. The first time your application creates the dialog box, you specify the first string, which can be any nonempty string. When the user selects a file, the dialog box copies the current filter pattern to the second string. The preserved filter pattern can be one of the patterns specified in the lpstrFilter buffer, or it can be a filter pattern typed by the user. The system uses the strings to initialize the user-defined file filter the next time the dialog box is created. If the nFilterIndex member is zero, the dialog box uses the custom filter.
If this member is NULL, the dialog box does not preserve user-defined filter patterns.
If this member is not NULL, the value of the nMaxCustFilter member must specify the size, in bytes (ANSI version) or 16-bit characters (Unicode version), of the lpstrCustomFilter buffer.
nMaxCustFilter
Specifies the size, in bytes or characters, of the buffer identified by lpstrCustomFilter. This buffer should be at least 40 characters long. This member is ignored if lpstrCustomFilter is NULL or points to a NULL string.
nFilterIndex
Specifies the index of the currently selected filter in the File Types control. The buffer pointed to by lpstrFilter contains pairs of strings that define the filters. The first pair of strings has an index value of 1, the second pair 2, and so on. An index of zero indicates the custom filter specified by lpstrCustomFilter. You can specify an index on input to indicate the initial filter description and filter pattern for the dialog box. When the user selects a file, nFilterIndex returns the index of the currently displayed filter.
If nFilterIndex is zero and lpstrCustomFilter is NULL, the system uses the first filter in the lpstrFilter buffer. If all three members are zero or NULL, the system does not use any filters and does not show any files in the file list control of the dialog box.
lpstrFile
Pointer to a buffer that contains a filename used to initialize the File Name edit control. The first character of this buffer must be NULL if initialization is not necessary. When the GetOpenFileName or GetSaveFileName function returns successfully, this buffer contains the drive designator, path, filename, and extension of the selected file.
If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the buffer contains the current directory followed by the filenames of the selected files. For Explorer-style dialog boxes, the directory and filename strings are NULL separated, with an extra NULL character after the last filename. For old-style dialog boxes, the strings are space separated and the function uses short filenames for filenames with spaces. You can use theFindFirstFile function to convert between long and short filenames.
If the buffer is too small, the function returns FALSE and the CommDlgExtendedError function returns FNERR_BUFFERTOOSMALL. In this case, the first two bytes of the lpstrFile buffer contain the required size, in bytes or characters.
nMaxFile
Specifies the size, in bytes (ANSI version) or 16-bit characters (Unicode version), of the buffer pointed to by lpstrFile. The GetOpenFileName and GetSaveFileName functions return FALSE if the buffer is too small to contain the file information. The buffer should be at least 256 characters long.
lpstrFileTitle
Pointer to a buffer that receives the filename and extension (without path information) of the selected file. This member can be NULL.
nMaxFileTitle
Specifies the size, in bytes (ANSI version) or 16-bit characters (Unicode version), of the buffer pointed to by lpstrFileTitle. This member is ignored if lpstrFileTitle is NULL.
lpstrInitialDir
Pointer to a string that specifies the initial file directory.
Windows NT 5.0 and later; Windows 98 and later:
If lpstrInitalDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.
If lpstrInitalDir is NULL and the current directory does not contain any files of the specified filter types, the initial directory is the personal files directory of the current user. To specify the current user's personal files directory as the initial directory, set lpstrInitialDir to the path returned by calling theSHGetSpecialFolderLocation function with the CSIDL_PERSONAL flag.
Earlier versions of Windows and Windows NT:
If lpstrInitalDir is NULL, the initial directory is the current directory.
lpstrTitle
Pointer to a string to be placed in the title bar of the dialog box. If this member is NULL, the system uses the default title (that is, Save As or Open).
Flags
A set of bit flags you can use to initialize the dialog box. When the dialog box returns, it sets these flags to indicate the user's input. This member can be a combination of the following flags: Flag Meaning
OFN_ALLOWMULTISELECT
Specifies that the File Name list box allows multiple selections. If you also set the OFN_EXPLORER flag, the dialog box uses the Explorer-style user interface; otherwise, it uses the old-style user interface.
If the user selects more than one file, the lpstrFile buffer returns the path to the current directory followed by the filenames of the selected files. The nFileOffset member is the offset, in bytes or characters, to the first filename, and the nFileExtension member is not used. For Explorer-style dialog boxes, the directory and filename strings are NULL separated, with an extra NULL character after the last filename. This format enables the Explorer-style dialogs to return long filenames that include spaces. For old-style dialog boxes, the directory and filename strings are separated by spaces and the function uses short filenames for filenames with spaces. You can use theFindFirstFile function to convert between long and short filenames.
If you specify a custom template for an old-style dialog box, the definition of the File Name list box must contain the LBS_EXTENDEDSEL value.
OFN_CREATEPROMPT
If the user specifies a file that does not exist, this flag causes the dialog box to prompt the user for permission to create the file. If the user chooses to create the file, the dialog box closes and the function returns the specified name; otherwise, the dialog box remains open. If you use this flag with the OFN_ALLOWMULTISELECT flag, the dialog box allows the user to specify only one nonexistent file.
OFN_ENABLEHOOK
Enables the hook function specified in the lpfnHook member.
OFN_ENABLESIZING
Windows NT 5.0, Windows 98: Enables the Explorer-style dialog box to be resized using either the mouse or the keyboard. By default, the Explorer-style Open and Save As dialog boxes allow the dialog box to be resized regardless of whether this flag is set. This flag is necessary only if you provide a hook procedure or custom template. The old-style dialog box does not permit resizing.
OFN_ENABLETEMPLATE
Indicates that the lpTemplateName member points to the name of a dialog template resource in the module identified by the hInstance member.
If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box.
OFN_ENABLETEMPLATEHANDLE
Indicates that the hInstance member identifies a data block that contains a preloaded dialog box template. The system ignores the lpTemplateName if this flag is specified.
If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box.
OFN_EXPLORER
Indicates that any customizations made to the Open or Save As dialog box use the new Explorer-style customization methods. For more information, see Explorer-Style Hook Procedures and Explorer-Style Custom Templates.
By default, the Open and Save As dialog boxes use the Explorer-style user interface regardless of whether this flag is set. This flag is necessary only if you provide a hook procedure or custom template, or set the OFN_ALLOWMULTISELECT flag.
If you want the old-style user interface, omit the OFN_EXPLORER flag and provide a replacement old-style template or hook procedure. If you want the old style but do not need a custom template or hook procedure, simply provide a hook procedure that always returns FALSE.
OFN_EXTENSIONDIFFERENT
Specifies that the user typed a filename extension that differs from the extension specified by lpstrDefExt. The function does not use this flag if lpstrDefExt is NULL.
OFN_FILEMUSTEXIST
Specifies that the user can type only names of existing files in the File Name entry field. If this flag is specified and the user enters an invalid name, the dialog box procedure displays a warning in a message box. If this flag is specified, the OFN_PATHMUSTEXIST flag is also used.
OFN_HIDEREADONLY
Hides the Read Only check box.
OFN_LONGNAMES
For old-style dialog boxes, this flag causes the dialog box to use long filenames. If this flag is not specified, or if the OFN_ALLOWMULTISELECT flag is also set, old-style dialog boxes use short filenames (8.3 format) for filenames with spaces.
Explorer-style dialog boxes ignore this flag and always display long filenames.
OFN_NOCHANGEDIR
Restores the current directory to its original value if the user changed the directory while searching for files.
OFN_NODEREFERENCELINKS
Directs the dialog box to return the path and filename of the selected shortcut (.LNK) file. If this value is not given, the dialog box returns the path and filename of the file referenced by the shortcut
OFN_NOLONGNAMES
For old-style dialog boxes, this flag causes the dialog box to use short filenames (8.3 format).
Explorer-style dialog boxes ignore this flag and always display long filenames.
OFN_NONETWORKBUTTON
Hides and disables the Network button.
OFN_NOREADONLYRETURN
Specifies that the returned file does not have the Read Only check box checked and is not in a write-protected directory.
OFN_NOTESTFILECREATE
Specifies that the file is not created before the dialog box is closed. This flag should be specified if the application saves the file on a create-nonmodify network share. When an application specifies this flag, the library does not check for write protection, a full disk, an open drive door, or network protection. Applications using this flag must perform file operations carefully, because a file cannot be reopened once it is closed.
OFN_NOVALIDATE
Specifies that the common dialog boxes allow invalid characters in the returned filename. Typically, the calling application uses a hook procedure that checks the filename by using the FILEOKSTRING message. If the text box in the edit control is empty or contains nothing but spaces, the lists of files and directories are updated. If the text box in the edit control contains anything else, nFileOffset and nFileExtension are set to values generated by parsing the text. No default extension is added to the text, nor is text copied to the buffer specified by lpstrFileTitle.
If the value specified by nFileOffset is less than zero, the filename is invalid. Otherwise, the filename is valid, and nFileExtension and nFileOffset can be used as if the OFN_NOVALIDATE flag had not been specified.
OFN_OVERWRITEPROMPT
Causes the Save As dialog box to generate a message box if the selected file already exists. The user must confirm whether to overwrite the file.
OFN_PATHMUSTEXIST
Specifies that the user can type only valid paths and filenames. If this flag is used and the user types an invalid path and filename in the File Name entry field, the dialog box function displays a warning in a message box.
OFN_READONLY
Causes the Read Only check box to be checked initially when the dialog box is created. This flag indicates the state of the Read Only check box when the dialog box is closed.
OFN_SHAREAWARE
Specifies that if a call to theOpenFile function fails because of a network sharing violation, the error is ignored and the dialog box returns the selected filename.
If this flag is not set, the dialog box notifies your hook procedure when a network sharing violation occurs for the filename specified by the user. If you set the OFN_EXPLORER flag, the dialog box sends the CDN_SHAREVIOLATION message to the hook procedure. If you do not set OFN_EXPLORER, the dialog box sends the SHAREVISTRING registered message to the hook procedure.
OFN_SHOWHELP
Causes the dialog box to display the Help button. The hwndOwner member must specify the window to receive the HELPMSGSTRING registered messages that the dialog box sends when the user clicks the Help button.
An Explorer-style dialog box sends a CDN_HELP notification message to your hook procedure when the user clicks the Help button.
nFileOffset
Specifies the zero-based offset, in bytes (ANSI version) or 16-bit characters (Unicode version), from the beginning of the path to the filename in the string pointed to by lpstrFile. For example, if lpstrFile points to the following string, "c:\dir1\dir2\file.ext", this member contains the value 13 to indicate the offset of the "file.ext" string.
If the user selects more than one file, nFileOffset is the offset to the first filename.
nFileExtension
Specifies the zero-based offset, in bytes (ANSI version) or 16-bit characters (Unicode version), from the beginning of the path to the filename extension in the string pointed to by lpstrFile. For example, if lpstrFile points to the following string, "c:\dir1\dir2\file.ext", this member contains the value 18. If the user did not type an extension and lpstrDefExt is NULL, this member specifies an offset to the terminating null character. If the user typed "." as the last character in the filename, this member specifies zero.
lpstrDefExt
Points to a buffer that contains the default extension. GetOpenFileName and GetSaveFileName append this extension to the filename if the user fails to type an extension. This string can be any length, but only the first three characters are appended. The string should not contain a period (.). If this member is NULL and the user fails to type an extension, no extension is appended.
lCustData
Specifies application-defined data that the system passes to the hook procedure identified by the lpfnHook member. When the system sends the WM_INITDIALOG message to the hook procedure, the message's lParam parameter is a pointer to the OPENFILENAME structure specified when the dialog box was created. The hook procedure can use this pointer to get the lCustData value.
lpfnHook
Pointer to a hook procedure. This member is ignored unless the Flags member includes the OFN_ENABLEHOOK flag.
If the OFN_EXPLORER flag is not set in the Flags member, lpfnHook is a pointer to an OFNHookProcOldStyle hook procedure that receives messages intended for the dialog box. The hook procedure returns FALSE to pass a message to the default dialog box procedure or TRUE to discard the message.
If OFN_EXPLORER is set, lpfnHook is a pointer to an OFNHookProc hook procedure. The hook procedure receives notification messages sent from the dialog box. The hook procedure also receives messages for any additional controls that you defined by specifying a child dialog template. The hook procedure does not receive messages intended for the standard controls of the default dialog box.
lpTemplateName
Pointer to a null-terminated string that names a dialog template resource in the module identified by the hInstance member. For numbered dialog box resources, this can be a value returned by the MAKEINTRESOURCE macro. This member is ignored unless the OFN_ENABLETEMPLATE flag is set in the Flags member.
If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in commdlg.h.
Unicode: Defined as Unicode and ANSI structures.
See Also
Common Dialog Box Library Overview, Common Dialog Box Structures, GetOpenFileName, GetSaveFileName,SHGetSpecialFolderLocation
d
|
|
|
|
|
You can set the OPENFILENAME structure .
d
|
|
|
|
|
I want to get localhost's IP address ?
I want to get localhost's gateway?
GFLPOWER
|
|
|
|
|
Try this:
DWORD GetLocalIP()
{
static char sName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD dwLen = sizeof(sName);
GetComputerName(sName, &dwLen);
HOSTENT *host = gethostbyname(sName);
DWORD dwIP = 0;
if(host->h_addr_list[0] != 0)
{
dwIP <<= 8;
dwIP |= (BYTE)(host->h_addr_list[0][0]);
dwIP <<= 8;
dwIP |= (BYTE)(host->h_addr_list[0][1]);
dwIP <<= 8;
dwIP |= (BYTE)(host->h_addr_list[0][2]);
dwIP <<= 8;
dwIP |= (BYTE)(host->h_addr_list[0][3]);
}
return dwIP;
}
|
|
|
|
|
Bad assumption. You should use the ntohXX functions to convert from network format to host. You never know, one day you will write code that isn't destined to run on an x86 box.
I migrated stuff between m68k, x86 and Sparc. Trust me on this, it's not fun.
Steve S
|
|
|
|
|
ntohXX functions are very very slow, you shouldn't use them at all, I've written an own version with does the whole job with about 10 clocks.
Don't try it, just do it!
|
|
|
|
|
which, presumably, are using either handwritten assembly functions, or inline assembly?
Which kind of defeats the purpose, which is platform-endian neutrality.
I didn't say they were speed efficient, but they help you produce portable code.
Steve S
|
|
|
|
|
I have a database program, and a dialog box that is full of Edit Boxes. After clicking the 'add new record' button, I would like the cursor to go back to the first box in the window.
If the first edit box is edit1, would you call something like SetCursor(edit1) or something like that?
Thanks!
Dimenser
|
|
|
|
|
GetDlgItem (edit1)->SetFocus();
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I want to open a window,that will have a text field,several "combo box" with some options,a "Ok" button, and another field where I want to show an image(initially empty). After selecting the desired options and pressing the "Ok" button,I want to show an image. The image shown will deppend on the options. Can you tell me please how can I do this?
(*Clarification*: The image is not an image on the disk,but something that will be generated from the options selected)
|
|
|
|
|
Make the image a bitmap, assign it a name, like IDC_IMAGE. In the class wizard, go to member variables and Add Variable, and make it a control called m_image. Then import or create the bitmaps you want.
In the Init Dialog section after it says, add extra initilization here, put
VERIFY(picture1.LoadBitmap(IDB_MYPICTURE1));
VERIFY(picture2.LoadBitmap(IDB_MYPICTURE2));
Create two variables of CBitmap type and name them picture1 and picture 2.
Then, in the part where you make your choice,
if (buttonpressed==1) m_image.SetBitmap(picture1);
if (buttonpressed==2) m_image.SetBitmap(picture2);
I don't think I left anything out, and this works for me in visual c++ 6.
Dimenser
|
|
|
|
|
I have something like this:
CDC* my_DC;
my_DC = new CDC;
my_DC -> CreateCompatibleDC(NULL);
my_DC -> PatBlt(0,0,my_size,my_size,WHITENESS);
for (int i = 0; i < my_size; ++i )
for (int j = 0; j < my_size; ++j )
if (result[i][j])
my_DC->SetPixel( i, j, RGB(0, 0, 0));
How can I make a Bitmap from that?
Thanks!
|
|
|
|
|
im trying to use a Print("") function with my own lang. it finds the Print("") but wont print whats between the "".
heres the code.
if(!strcmp(parsel.c_str(),"Print(\"") || !strcmp(parsel.c_str(),"Print (\""))<br />
{<br />
<br />
<br />
int at = parsel.find("Print(\"",0);
int at2;
bool flag = 1;
<br />
if( at = string::npos)<br />
{ <br />
flag = 0; <br />
at2 = parsel.find("Print (\"",0);<br />
at2 += 8;<br />
}else<br />
{at += 7;}<br />
<br />
while( flag )<br />
{<br />
at++;<br />
int pos;
bool run = 1;
while( run )<br />
{<br />
string test = parsel.substr(at, 1);<br />
if(! strcmp(test.c_str(),"\""))<br />
{ <br />
at++;<br />
pos++;<br />
}<br />
else{ <br />
run = 0;<br />
at = at - pos;<br />
string tmp = parsel.substr(at, pos);<br />
cout << tmp;<br />
}<br />
} <br />
}<br />
if(! flag)<br />
{<br />
at2++;<br />
int pos;<br />
bool run = 1;<br />
while( run )<br />
{<br />
string test = parsel.substr(at2, 1);<br />
if(! strcmp(test.c_str(),"\""))<br />
{<br />
at2++;<br />
pos++;<br />
}<br />
else<br />
{<br />
run = 0;<br />
at2 = at2 - pos;<br />
string printer = parsel.substr(at2, pos);<br />
cout << printer;<br />
}<br />
}<br />
}<br />
<br />
} <br />
}
|
|
|
|
|
|
I am using Marc's EasySize.h for easy resizing of controls within a dialog-based application. I need help with getting the message map right for the following controls:
1) I have two list controls side-by-side that I want to resize proportionately to the resize. How do I code the message map for the easy size?
EASYSIZE( control, left, top, right, bottom, options )
2) Also in the dialog I have 5 buttons that are lined up on the bottom of the dialog centered horizontally. Can someone help me get the message map right for these controls as well?
THANKS!
|
|
|
|
|
Can u be a bit more specific about ur question? what exactly do u need?
Do you want to know how to resize the controls, or how your function works?
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
If you download the source code of the following article , you will see examples of different alignments of controls.
- Michael Haephrati מיכאל האפרתי
|
|
|
|
|
visual C++
1. i have created a dialog based project COldDlg.
2. then i added a new dialog resource CNewDlg.
3. i need that the old dialog sees the new one and controls its member variables and when the OnOK() of the new dialog executes it returns to the old dialog.
in other words i need to achieve the following commands:
COldDlg::OnCalculate()
{
CNewDlg dlg2;
dlg2.DoModal();
m_new=m_old;// where m_old,m_new are 2 member variables of the old and new dialoge respectively
}
when i made the above statements the builder tells me that CNewDlg is undefined declaration.
can anyone give me a detailed answer(in steps and forward plzzzzzzz)
i can rebuild the new dialog again if needed
|
|
|
|
|