|
Try instead to overwrite the m_ofn member lpstrFile to contain the full folder path,
either "c:\DocFiles" or "c:\TxtFiles".
|
|
|
|
|
sorry, it doesn't work
I Try, but I'm not sure  )
|
|
|
|
|
Could you post your implementation?
|
|
|
|
|
I try 2 solution:
void MyClass::OnTypeChange()
{
if(m_ofn.nFilterIndex==2){ // .doc
char szPath [MAX_PATH] = {"c:\\DocFiles"};
SetCurrentDirectory(szPath);
m_ofn.lpstrFile=szPath;
} else { // .txt
char szPath2 [MAX_PATH] = {"c:\\TxtFiles"};
SetCurrentDirectory(szPath2);
m_ofn.lpstrFile=szPath2;
}
Invalidate();
UpdateData(false);
}
and
void MyClass::OnTypeChange()
{
if(m_ofn.nFilterIndex==2){ // .doc
char szPath [MAX_PATH] = {"c:\\DocFiles\\file.doc"};
//SetCurrentDirectory(szPath);
m_ofn.lpstrFile=szPath;
} else { // .txt
char szPath2 [MAX_PATH] = {"c:\\TxtFiles\\file.txt"};
//SetCurrentDirectory(szPath2);
m_ofn.lpstrFile=szPath2;
}
Invalidate();
UpdateData(false);
}
But don't work.
N.B.: c:\DocFiles\file.doc and c:\TxtFiles\file.txt are existing files on the disk.
I Try, but I'm not sure  )
|
|
|
|
|
Have you already customized your CFileDialog?
|
|
|
|
|
not yet
I Try, but I'm not sure  )
|
|
|
|
|
In a winAPI project, I am generating dialog templates at compile time, but not setting the positions and sizes of the controls until runtime because they depend on the font, which I set to whatever the user has set as their lfMessageFont at runtime. One of the dialogs has an up-down control with a static control set as its buddy window. For the sake of consistency, I would like the up-down control to be positioned and sized according to the standards of the UDS_ALIGNRIGHT style. However, it seems that setting that style only suffices to position the up-down control according to the position and size of the buddy window as specified in the dialog template, and when I resize the buddy window when handling the dialog's WM_INITDIALOG message, the up-down control doesn't change with it. Is there a way to manually invoke the UDS_ALIGNRIGHT code again at this point? Or do I need to switch to generating the entire dialog template at runtime if I want to keep the effects of that style?
|
|
|
|
|
If you are adjusting size and position at run time, then you need to re-measure each control according to the new values that affect it. You also need to check any option settings on each control that may affect the layout. In your case the setting for UDS_ALIGNRIGHT will affect the control it is set on (the up/down) and the buddy window. See Up-Down Control Styles (CommCtrl.h) - Win32 apps | Microsoft Docs[^] for further information.
[edit]
You could load the resource dialog into memory and change the font details at runtime, and then invoke the dialog from the memory template. I am not 100% sure if that will work but a quick test should confirm it.
[/edit]
|
|
|
|
|
Inserting the font details into the template would save me having to send WM_SETFONT to every control in the dialog that has text while handling WM_INITDIALOG, as I do now, but I don't see what difference it would make in positioning the controls. One of the tools I use to determine the layout is Button_GetIdealSize, which I Can't call until I have an HWND for each control in question. As far as I can tell, that means I can't do it until I've instantiated an instance of the dialog. I guess I could instantiate an instance at startup, position and size the controls, alter the template to reflect the siz and position values this yields, then destroy the dialog. That way, each time an instance of the dialog is instantiated from then on, the layout will already be correct from the start. It seems like a rather tortured usage of the API, though.
I'm not sure what you mean by remeasuring each control. Out of context, I'd have guessed that would mean calling GetWindowRect on each control, but I believe I know what values that would return a priori; it should zero out the struct if I do it before reformatting the control, reflecting the zeroed-out dialog template, and if I do it after reformatting, it should return the values I just specified. I'm similarly confused about what it means to check the control's option settings.
|
|
|
|
|
|
I'm working on a project that involves an LL(k) parsing algorithm (or more accurately, a set of algorithms) which seem to be the best kept secret on the Internet.
The hunt for how to implement these took me back to C code written in 1989 and some citations for research papers dating back to 1992, which I can't seem to find a copy of the journal it was published in.
How do people even do LL(k)? How do they learn it? I understand how Terrence Parr (author of ANTLR) did as he has been instrumental in the crafting of LL(k) parsing algorithms for decades. He's no Aho & Ullman but he's a key player. He's the one that wrote that 1989 code I'm looking at.
I've found a few scattered research papers but the math is really heavy. You need a pretty advanced background in CS I think to understand it all.
But anyone else that wants to do this kind of thing? Good luck. If you can find the research it won't mean you can understand it, and I can't even find it, much less understand it. All the links are dead, and the citations I'm currently looking at lead to an out of print journal on information processing and information systems
It's ridiculous. No wonder there are so few implementations of this available (the major one by Terrence Parr himself)
Real programmers use butterflies
|
|
|
|
|
|
I'm surprised i didn't find that. I gues I should have dug around ANTLR's website. Thank you, this is a gem.
Real programmers use butterflies
|
|
|
|
|
Sometimes they all start looking the same. Glad if it helps.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Quote: the major one by Terrence Parr himself Who changes the 'damn thing' at each release in a way that irremediably invalidates the previous stuff... 
|
|
|
|
|
Hi,
I am using an MFC dialog (ANSI no Unicode) created in the resource editor with a nonlatin character name in its title, as a Property page.
While running the debug mode I can see the nonlatin title in release mode I get a gibberish characters.
What seems to be wrong here?
sdancer75
|
|
|
|
|
sdancer75 wrote: What seems to be wrong here? It is difficult to say without more information. Maybe some difference between Debug and Release settings. When you say "non Latin", what characters are you referring to?
|
|
|
|
|
Hi,
Thank you for your interest... Its the 1st time I meet this kind of problem. My Visual Studio is pretty old v2008 and the project settings are similar. Both Debug and Release share the same *.rc file.
They are both an MFC Static, not using ATL and Character Set are "not set".
My nonlatin character set is Greek. I can see the Greek titles in my dialog boxes in the editor. The only problem here is the Release version of the app. Don't know where to look for a problem.
Regards,
sdancer75
|
|
|
|
|
I think the Greek character set requires Unicode to display correctly. Try changing the settings on your project.
|
|
|
|
|
Hi,
I have used older projects with Greek characters in ANSI and code pages without problems.
Indeed unicode will solve the problem, but this specific project is too big and I have to make too many changes to finally make it work fine.
Anyway, I managed to fix the problem changing the title of the title dynamically inside the code.
Take in mind that when I recall strings from the Resource String Table using CString.LoadString(ID) I get gibberish but when I am using CStringW.LoadString(ID) it works. My String Table is not Unicode but inside VS2008 I set it up as Greek code page.
sdancer75
|
|
|
|
|
Two possible problems
1. In the project settings, make sure the character set is set to unicode for both debug and release
2. if you use third party libraries (other than MFC), make sure they also use unicode for both Debug and Release.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Hi,
Thanks for your reply. Indeed I am using a 3rd party library but they are all set to ANSI (no unicode at all). I fixed the problem by dynamically changing the Dialog Title.
Regards,
sdancer75
|
|
|
|
|
(the pre tag seems to be broken with the code)
const std::wstring expression( L"Value stored = $(_VARIABLE_NAME_)");
const std::wstring tmp(LR"(\$\(([^\(\)\$]*?)\))");
const std::wregex rx(tmp);
const std::wstring variableValue(L"A2347X$01GBFC");
std::match_results<std::wstring::const_iterator> matchResult;
const bool found = std::regex_search(expression, matchResult, rx);
if ( found )
{
const std::wstring expressionOut = std::regex_replace(expression, rx, variableValue, std::regex_constants::format_first_only);
std::wcout << "expressionOut = " << expressionOut << "!\n";
}
When I run the above code (or use Regex Tester )
(I added the bold)
expressionOut = Value stored = A2347X_VARIABLE_NAME_GBFC
I was expecting (or I am wanting) the result to be
expressionOut = Value stored = A2347X$01GBFC
Is there a way to treat the input "A2347X$01GBFC" as a "raw" input and not something to be parsed by the std::regex_replace ?
In our case, the string "A2347X$01GBFC" is something that a user can input manually.
I'm certain there is an way to do it, but I cannot see it.
Thanks.
I'd rather be phishing!
|
|
|
|
|
I can't see it either. It seems you've got two options, either use format_sed, if you know that you wont have \1 in the replacement string, or you'll have to turn any single $ into $$ before passing in to regex_replace There really should be a format_no_format flag to turn off format replacements.
|
|
|
|
|
Awesome! Thanks.
Will try monday.
I'd rather be phishing!
|
|
|
|