|
benjymous wrote:
it's basically telling the compiler to treat the variable data as if it was of type unsigned char*
where would that be used?
Any place where I can read more about it?
Tx for the help guys
|
|
|
|
|
The line:
{ // <-- Colored with red by Instant Match
Makes me suspect that this was autogenerated by some other program. I have no idea what that could be. (though it might be one of your comments and I misunderstood it) In general machine generated source code is difficult to understand.
The things confusing you are rarely used C abilities. Look them up in a book, you may need them latter, but don't worry about understanding exactly what they are doing until you are more advanced. You can program for a long time without needing any of these tricky parts.
I'm assuming that you are just reading this code. If you picked it because there is a reason you want to change it, then go slow. This is some tricky stuff.
n = bits_of_data > 8 ? 8 : bits_of_data;
You are setting n to something. Others have explained exactly what just fine. The important thing to remember when you see the "? :" operator is that n is important, not the if statement to decide what to set it too. Many programers live their entire life without using "? :", but experts know that used correctly it can make your code more readable. if else should be used far more often.
|
|
|
|
|
I came across the code while searching for a nice hex viewer/editor, so I have no idea who/what wrote it.
One more thing: I see the variables accepted by the procedure is unsigned char *bit_stream and unsigned long & bit_offset, which if I remember correctly * refers to the the address and & to the value, or how should that be interpreted? how do you know which to use?
tx for the help
|
|
|
|
|
No in fact the * is the indirection operator. It is used to access the value pointed by a pointer. So, when you declare a pointer (int* pTest for example), it must be read like that: "the value pointed by pTest is an integer". So, it means that pTest is a pointer.
The & represent the adress of something (can be a value, a char, or even a pointer...). So, when you write
int Value = 0; , &Value represent the adress of your integer...
So applying this in your case in the function, when you write unsigned char* bit_stream means that you are passing not the value but the pointer to an unsigned char.
For your second argument, this is a little bit different: when you use the & for one of your parameter of your function, that means that this parameter is passed by reference and not by value. In other word that means implicitely that the adress of your variable is passed to the function and so, if you modify the content of it, it will be visible outside of your func (the function doesn't make a copy of the value but work directly on it).
In general you use the pointer (*) when you need to pass an array, and you use the (&) when you need to get a value from your function (but without returning it with return...).
Hope this is a little bit clearer
|
|
|
|
|
yes, I think I've got it. A pointer is used when the value of an array will (probably) be changed in the procedure, and a & is used if only a value is needed.
tx indeed.
|
|
|
|
|
Brakanjan wrote:
A pointer is used when the value of an array will (probably) be changed in the procedure
Not really, it can be used also just to pass an array (even when you don't need to modify things in it). You can just pass an array by supplying the adress of its first element... And an array contains more than one value (by definition ).
But in essence this is it
|
|
|
|
|
I have seen applications where the initial data entry dialog is small but when the user selects the 'Advance' option a lot more information is displayed on a larger dialog.
Does anyone know how this is done as I would like to display a listCtrl, buttons and labels when the use selects the 'More Information' options on a small dialog.
Regards,
|
|
|
|
|
Does anyone know how this is done
yes.
when the user clicks on "more infor", you need to manually resize the dialog, that will make the controls "visible" or not to the user.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
A little more information would be useful. Do I use the SetWindowPos() to be a small dialog at initialisation and then resize to a larger dialog when the 'More Info' button is hit?
Is it trial and error to guess the units/size?
|
|
|
|
|
MFC measures dialogs in a ratio of the font size, so it can be a bit hit or miss (try changing your system font size to be bigger, then run your app, and you'll see it's got bigger too!)
I did something like what you're attempting in the past, and found the easiest solution was to add a simple frame at the bottom (the size of the area that gets shown/hidden)
At run time, you can find the height of this control, and resize the dialog window accordingly - this'll make it much easier if you keep going back to add extra controls to the "hidden" part
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Hi,
You can simply use MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRedraw = FALSE) on the click on 'More Settings' button and expand/collapse the dialog using required width and height.
This will solve ur problem.
Vikram Kashyap
Sr. Software Engineer
TechBooks International
R&D Division
|
|
|
|
|
sweep123 wrote:
Does anyone know how this is done...
Yes. See the "Expanding and Contracting your dialog boxes" section of this article for an example. Here is another example, in the "More / Less Detail on Dialog" section.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
This is surely an easy q for you but I don’t remember how to do it…
How do I get the size of the users screen?
_____________________________
...and justice for all
APe
|
|
|
|
|
HDC tmpDC = GetDC(NULL);<br />
int xRes = GetDeviceCaps(tmpDC,HORZRES);<br />
int yRes = GetDeviceCaps(tmpDC,VERTRES);<br />
|
|
|
|
|
GetClientRect(hWnd, &clientRect);
|
|
|
|
|
Use this one...
int cx = GetSystemMetrics(SM_CXSCREEN); // return the width in pixels
int cy = GetSystemMetrics(SM_CYSCREEN); // return the height in pixels
Vikram Kashyap
Sr. Software Engineer
TechBooks International
R&D Division
|
|
|
|
|
Tnx - My solution
_____________________________
...and justice for all
APe
|
|
|
|
|
See the 'GetSystemMetrics' function. You can get de screen metrics among many other parameters of the system
|
|
|
|
|
Hi,
I need to programmatically view the contents of a textual file. In order to open it in read-only mode, I use the following line :
<br />
::ShellExecute(0, "open", "iexplore", s_file, SW_SHOWNORMAL);<br />
This works on most cases, but when testing the program on a VMWare virtual machine I have observed that the following command line :
<br />
C: > start iexplore <path to s_file><br />
briefly displays a confirmation dialog box that dismisses itself immediately. The dialog box contains rougly the following message :
You are downloading the <path to="" s_file=""> file.
Do you want to open it or save it on the hard disk? [open][save][cancel]
What might go wrong?
Cheers.
--
Maxime Labelle
maxime.labelle@freesurf.fr
|
|
|
|
|
Do you have to use internet explorer to view the file contents? If it's a file that is associated with an application you would use the file name inplace of the iexplore..
ShellExecute(NULL, "open", s_file,/*params*/ NULL, /*working dir*/NULL, SW_SHOWNORMAL);
Hope this helps
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I need to create programmatically a self-executable zip file, which has exe as file extension, can be unzipped by winzip and can be executed by double click it.
some one gave me a link
http://www.codeproject.com/win32/selfextract.asp
example from the link is self-executable but can not be unzipped by winzip.
there are many exe files are in this way, for example, winzip itself (winzip80.exe) and java sdk (j2sdk1401.exe).
can you help me?
thx
includeh10
|
|
|
|
|
The example you linked to uses zlib compression rather than zip compression, which is why it isn't compatible with winzip
The basic format of a self-extractor is actually pretty simple
What you need to do is write some code that can extract a zip archive from an address in memory
You then create an exe containing this code, and another small tool that takes a zip file, and merges the zip with the exe (i.e. just append the zip data to the end of your exe)
The exe needs to know where to look (i.e. at the end of the code), and extract the zip data from there.
As long as you keep the zip file intact within the self extractor, without modifying it, then winzip should still be able to find the archive and extract it manually
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Hi
I created a AdoDatabase connection in my service. But when the system is logged off or shutdown it shows OleMainThreadWndName error.
This happens only in NT not in 2000 or later.
Any idea will be greatly appreciated. I have been looking for this for quite some time
Thanks in advance
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
|
Hi
Thankyou Lim Bio Liong for your answer.
I have had a look at this. But this is not the problem. OleMainThreadWndName error occurs because one you initialize COM using CoInitialize it creates some windows for databases.
Now if the service is running and I try to logout, the system cannot close those windows. And throws of errors.
So my question is how can I overcome that.
Please Help me....!
Regards
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|