|
Max,
The default constructor is in the documentation[^]:
CPrintDialog(
BOOL bPrintSetupOnly,
DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_HIDEPRINTTOFILE | PD_NOSELECTION,
CWnd* pParentWnd = NULL);
The default constructor does not contain PD_RETURNDEFAULT. You will need to use the PD_RETURNDEFAULT flag[^] to get the CPrintDialog class to simply return the default printer. In fact by using this flag the DoModal(); function won't even open a window.
CPrintDialog dlg(FALSE,PD_RETURNDEFAULT,NULL);
dlg.DoModal();
LPDEVMODE lpdev = dlg.GetDevMode();
MessageBox(lpdev->dmDeviceName,0,0);
Windows 10 makes decisions for the novice users. So Windows 10 will sometimes decide which printer to use and override the user choice. To disable this programmatically you could set the HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\LegacyDefaultPrinterMode to TRUE.
Best Wishes,
-David Delaune
|
|
|
|
|
lol, thanks.
I should really pickup this technical skill of RTFM.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
|
I have some basic knowledge about pointers and I`m trying to get an exhaustive understanding, like an all sides perspective. My question is what does the operator ++ do to a pointer? I`ve seen it being used in linked lists related code.
|
|
|
|
|
It is the increment operator, and as with any variable it adds 1 to the pointer. This will move the pointer forward by one element of whatever it is pointing to: int, long, struct, object etc.
|
|
|
|
|
could I increment not the value of the variable the pointer is pointing to but the pointer itself?
int Something0 = 0;
int Something1 = 1;
int ** Pointers = new int*[2];
Pointers[0] = &Something0;
*Pointers[0]++;
Pointers[1] = &Something1;
*Pointers[1]++;
**Pointers =10;
Pointers++;
**Pointers =30;
|
|
|
|
|
That's what the increment operator does to a pointer - it increments the pointer itself.
If you want to increment the value that it's pointing to, you must dereference the pointer first, like so: (*pointer)++;
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thanks I think I understand.
|
|
|
|
|
You should also know about the difference between a pre-increment and post-increment operator. In an expression, a pre-increment operator computes the increment before accessing the item, and a post-increment computes the increment afterwards. For example
int i = 1;
int j = ++i; int k = i++; int x = ++i++; In the case ++i++ The standard does not say what will happen. The only thing you know is that i will have the value 5 after the expression is complete. The variable x could be assigned at any point during the expression, or since this is undefined behavior, it might even get the value -42, which makes no sense in respect to the code, but is acceptable according to C/C++ standard. Even if you do some testing and work out that for type int the expression ++i++ is the equivalent of ++(i++) , it might be different for type long , or for a pointer type, and it might change depending on complexity of the overall expression, and/or the optimization level. The takeaway for this is that you don't know what will happen if you try to pre and post increment an expressions term at the same time. Moreover, you should not try to increment the same variable within the same expression:
int i = 2;
printf("%d %d\n", i++, ++);
In the printf statement above, its undefined which order the arguments to printf get evaluated, and different compilers do it differently. I'm reasonably sure that clang and gcc do this differently.
Keep Calm and Carry On
|
|
|
|
|
thanks k5054. I`m not sure I fully understand the difference. I guess I need look up the issue in several different sources. (I often find consulting different perspectives on the same issue helpful).
modified 16-Nov-21 17:41pm.
|
|
|
|
|
|
|
I am guessing that
k5054 wrote:
int i = 2;
printf("%d %d\n", i++, ++); should have read as
int i = 2;
printf("%d %d\n", i++, ++i);
|
|
|
|
|
Yes, of course. My bad.
Keep Calm and Carry On
|
|
|
|
|
A while ago I`m started making a c++ code debugger tool in Forms (C#). The tool is designed to spot faults in a c++ code file and works such that in the process no compilation is taking place. It`s basically a simulation of execution without a binary file being involved. Are there similar projects around?
|
|
|
|
|
CalinNegru(fearless_) wrote: It`s basically a simulation of execution without a binary file being involved Sorry, I don't have an answer for you, but wow, that's sounds incredibly ambitious.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
It`s similar to what Visual Studio Intellisense does just driven one step further
|
|
|
|
|
Simulating execution versus providing context sensitive help seems like a BIG step, at least to me. I'm not dismissing Intellisense, which I imagine is a very large and complex task itself.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Itellisense keeps track of variables (which involves the creation of some sort of structures to hold at least the variable name and type) and brackets, but I agree it`s all on a very shallow level. I thought storing variable values would be the next logical step. Getting on this track started from me being frustrated with silent errors one gets when accessing an array outside its bounds. You could fix this by adding safety checks around the array in the c++ code but I thought you could also have an Intellisense like system that would spot the error. Evolving it into something that can `understand` classes or other advanced c++ features is an ambitious undertaking indeed I`m not sure I`m aiming that high.
here`s a short video of my program performing some basic operations:
Simulating code execution - YouTube[^]
modified 11-Nov-21 5:03am.
|
|
|
|
|
I'm not sure, excactly, what it is you're trying to accomplish. If you're thinking of creating a full C++ interpreter, then maybe you want to look at the Cling - ROOT project. However, that is a Linux only project, so it probably wont fit your needs. There might be a good C++ interpreter available for windows out there, you'll just have to google for it.
If what you are trying to achieve is more along the lines of code analysis, then maybe clang-tidy is more what you are thinking of, in which case see here: Using Clang-Tidy in Visual Studio | Microsoft Docs
But maybe I've misunderstood what it is you're trying to do. Perhaps the exercise of writing a C++ parser is in itself worth the effort for you, in which case, have at it!
Keep Calm and Carry On
|
|
|
|
|
thanks I`ll take a look at those projects to see if they are a match to what I`m trying to build. Note: I could be misusing the term `interpreter` here, that could be a word that is used to designate a very specific thing in software development.
modified 11-Nov-21 2:01am.
|
|
|
|
|
Interpreter usually means software that executes source code without compiling it.
Depending on what you want to do, the code associated with this article[^] may be useful. To do C++ static analysis, it has to do many of the same things as a C++ compiler. However, it is written in C++, not C#.
|
|
|
|
|
I`m making proper use of the term then. Thanks for the article link Greg
|
|
|
|
|
The code in the article could evolve into a C++ interpreter, but I decided this wouldn't be as useful as enhancing its static analysis capabilities. There are also C++11 language features that it doesn't support, and it doesn't do folding (calculating compile-time constants).
|
|
|
|
|
I`ll probably won`t end-up much further than getting my feet wet but that good to know.
|
|
|
|