|
I am having a problem with this function. It always returns FALSE and then CommDlgExtendedError() returns CDERR_INITIALIZATION.
MSDN says CDERR_INITIALIZATION is caused by low memory but I dont think this is the problem. I have rebooted my machine and other apps are able to display this dialog. Originally this code was in a ATL project for a MapPoint Add In. I have copyed it into a simple dialog based MFC app and still have the same problem.
can anyone help?
I have the following
OPENFILENAME ofn;
char szFile[512];
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = NULL;
ofn.lpstrFile = szFile;
ofn.nMaxFile = 512;
ofn.lpstrFilter = "All\0*.*\0TT Route Log\0*.TRL\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
BOOL b = GetOpenFileName(&ofn);
DWORD err = CommDlgExtendedError();
|
|
|
|
|
I did not find anything inherently wrong with your code snippet as it worked fine for me with no changes. A few things you *might* want to consider would be:
char szFile[512] = {'\0'};
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All (*.*)\0*.*\0TT Route Log (*.TRL)\0*.TRL\0"; While they don't hurt anything, the statements that assign NULL and 0 to the other structure members are not necessary. ZeroMemory() has already handled that.
Also, check out MSDN article Q222003.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Haven't tried the actual code, but the one thing I notice is
ofn.lpstrFilter = "All\0*.*\0TT Route Log\0*.TRL\0";
lpstrFilter needs to de double NULL terminated, like
ofn.lpstrFilter = "All\0*.*\0TT Route Log\0*.TRL\0\0";
|
|
|
|
|
That fixed it. Thank you very much. Im suprised because that code was copied straight from MSDN
|
|
|
|
|
The is an implied \0 at the end of every string literal. So the string "All\0*.*\0TT Route Log\0*.TRL\0\0" actually end with three of them.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello:
I'm trying to do a proirity_queue like this:
#include < queue ><br />
using namespace std;<br />
<br />
struct stman{<br />
int age;<br />
double Height;<br />
char Name[255];<br />
}<br />
<br />
priority_queue <stman> myQueue;<br />
stman sMan;<br />
<br />
int main(){<br />
<br />
myQueue.push(sMan);<br />
<br />
}
The code here does nothing... but it explains the trouble in what i am, i can't save these tipe of struct into the queue, and order the priority based in the age of any instance of the struct.
The question is... someone knows how solve it???
Thank you in advance
|
|
|
|
|
|
I have a problem in changing the position of a checkbox control during runtime.
i created the checkbox control during runtime also.
i have tried using SendMessage
SendMessage(GetDlgItem(hwnd,IDD_PIN_BUTTON + (intPinChkCtr)), WM_MOVE, 0, MAKELPARAM( (WORD)rectDialog.left, (WORD)rectDialog.top++) );
during debug while watching the return of the GetWindowRect() it says that the controls top property has increased but it seems that the control has not moved its position in the dialog.
any suggestions?
thanks!
|
|
|
|
|
it is not very proper to combine such operations on the same line, especially when you do not / cannot know in which order it is executed...
in your :
SendMessage(GetDlgItem(hwnd,IDD_PIN_BUTTON + (intPinChkCtr)), WM_MOVE, 0, MAKELPARAM( (WORD)rectDialog.left, (WORD)rectDialog.top++) );
are you sure the rectDialog.top++ is executed before the GetDlgItem() funciton is executed ?
wouldn't it be better to write ++(rectDialog.top) , or better extract it before the line, then pass the value ?
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
thanks for the suggestion.
i tried it but it seems that the incremented top position was not kept.
during debug the top value would change but if i would be going back to the break point
again the previous top value was retained.
GetWindowRect( GetDlgItem(hwnd,IDD_PIN_BUTTON + (intPinChkCtr)), &rectDialog );
sizeDialog.cx = rectDialog.right - rectDialog.left;<br />
sizeDialog.cy = rectDialog.bottom - rectDialog.top;<br />
SendMessage(GetDlgItem(hwnd,IDD_PIN_BUTTON + (intPinChkCtr)), WM_MOVE, 0, MAKELPARAM( (WORD)rectDialog.left, (WORD)(++rectDialog.top)) );
it seems like the control was not keeping the changes from the SendMessage()
|
|
|
|
|
and what about SetWindosPos() instead of SendMessage() ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
daydremer wrote:
I have a problem in changing the position of a checkbox control during runtime
What about [MoveWindow] and [SetWindowPos] Api!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
it seem that alok have some trouble...
do you also click with your nose ?
or did you just forget the [Modify] link ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
do you also click with your nose ?
No Using Hand these days, After Cedric lost control!
toxcct wrote:
it seem that alok have some trouble...
DAMM 500 error doing this, i think my message is not posted , so i post it again
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
and what about [Delete] link now ?
(toxcct, looking at his watch : "Oh no, it's time to 3... the school's gonna disconnect the servers for 3 hours && 1/2 ... like every days how will i write my posts???)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
and what about [Delete] link now ?
YES OFFICER, IT WILL BE DONE, OVER AND OUT!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
toxcct wrote:
(toxcct, looking at his watch : "Oh no, it's time to 3... the school's gonna disconnect the servers for 3 hours && 1/2 ... like every days how will i write my posts???)
Ah yes, Alok we have an advantage the next hours...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote:
Ah yes, Alok we have an advantage the next hours...
Nope 3 and 1/2 hr (Oops 1/2 hr already passed )
Any way Now you are alone as i am logging off tooo, have nice DAY
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
LOL. I have to wait a few hours before I finish work and go home...
Have a nice day too
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
well, have a nice evening
i'm back, but not for a long time
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Well, I'm finished with my work so I head home now.
See you tomorrow
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
MoveWindow worked for me although it took me a while to figure out how the command works.
thanks a lot!
|
|
|
|
|
Hi all,
I got two unsigned chars that I need to convert into a unsigned short whereby the two chars act as the upper and lower bytes of the short. How do I go about this. It seems in my head to be a simple matter but I just can't figure it out.
Thank you in advance
Rich
|
|
|
|
|
<font color=blue>unsigned char</font> ucMSB = 0x6F,
ucLSB = 0xA4;
<font color=green>
<font color=blue>unsigned short</font> usVal = (((<font color=blue>unsigned short</font>)ucMSB) << 8) | ((<font color=blue>unsigned short</font>)ucLSB);
easy isn't it ?!
pssst: it seems that you have some troubles with bytes manipulation ; as it is not the first time you ask such question... what are you trying to do with all these ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thanks for the help guys.
What am I doing? I'm converting user input ( from gui ) into the smallest possible form ( hence the splitting of data ), transmit it to another source via serial comms which then sends a message back. The message then has to put back into a readable form so it can be displyed in the gui. I've got the Tx side of things sorted now but I'm just tying up the Rx data.
I knew it was simple but I just couldn't figure it out. Time to blow brains out I think.
|
|
|
|