|
Rajesh_K_Sharma wrote:
which one is better to use either union or struct.
Depends on Situations.But, personally I have never liked Union!.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
personally I have never liked Union!.
sometimes, it become THE feature to be used...
i remember a project i made last year, when i was programming for a microprocessor... we had to know how the processor memory was, where would be stored the hardware datas, and to implement this (wheter the periph was reading or writing), the datas was in distinct registries. but sometimes happend the fact that those two registries were at the same address...
so, what to use ? union s...
but i agree, it's not the most easy thing to learn about from C.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
when i was programming for a microprocessor... we had to know how the processor memory was,
Hi Tox,
As I don't program in MicroController/hardware, Unions would never be my first Choice.
That's just my personel feeling, I am not forcing any BODY to use structure instead of UNIONS.
It's always DEPENDS ON SITUATION which one is better,
let takes a example,if you want to keep Name and age of employee in a DATA STRUCTURE, your choice always would be STRUCTURE (in case of C ) as you don't want to mess up the data!.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
It's always DEPENDS ON SITUATION which one is better
that's logic, i entierly agree with you sir...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
sir...
.............It's a great Pleasure!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
This means that you have never needed union . There is nothing to like or not to like. In fact, the union was introduced by John von Neumann (first computer idea creator) at the beginning of 20th century, if I'm not wrong, when he presented interpretting of a memory word once as a machine code or secondly as a piece of data. Thus you have the ancient union .
|
|
|
|
|
liquid_ wrote:
This means that you have never needed union
Hello Mr Liquid,
I Believe, I am repeating myself i am application developer, It's really depend upon situation of project which thing will be better. you don't want to mess data of Student Name, Age and Class by using the UNION.
yeah i know UNION ar emuch better in other cases as mentioned by Mr Tox!
Thanks
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
using union is good think if u really know where to use n how to use it.
I pesonaly use union as annonymous inside class or struct coz suppose if u have more than one embeded class-object in some class n want to select any one of it then u can use union to allocate memory only for one of that, so no need to allocate memory for each n every embeded class-object, so union is good to use
|
|
|
|
|
to sum up,
use struct s when you don't have to make a choice and want all the members to be available at the same time,
use union s when datas can be hidden by some others, and the fact that another member write the same memory area shouldn't care.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I want to save a web page just from a url.that means i don't want to navigate to that url first.
I want all the resources are saved correctly. The links in the local page that saved must also be active.
One more,I don't use wbebrowser ctrl. There should not show a save as dialog box just like IE. The saving procress should be done silently.
Thank you everyone. Any ideas?
|
|
|
|
|
You need to connect to the site, and download the HTML. Then you can use a regex to trawl it for links to resources, and download those ( boost has a regex add in for C++ ). If you want the links on the page to work offline, then you need to change them to something local, and repeat the process for those pages, so they get downloaded as well, to the location that the new link points to. If you do this recursively, you'll need a big hard drive, and to do some checking for circular links.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Tcpip2005 wrote:
I want to save a web page just from a url.
Hello Mr TCPIP,
Please take a look at this Link:-
http://www.codeproject.com/internet/amhttputils.asp[^]
this article gives a brief overview and Wrapper class to save the webpage from a URL!.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
i get the handle of a textbox in an opened window using the function
EnumChildWindows(,,)..
after i obtained the handle of this textbox i want to set a specific
string in this textbox.
"HINT" : the function SetWindowText(,) isn't a valid to this task(why?)
more--->
the opened window has a textbox ,a button ,a label;
and when i used the spy++ program of Microsoft tools to get the caption
to each of them after using SetWindowtext(,),i observed that:
the caption of the label is same as the value appears on it<the
caption="" and="" value="" appears="" are="" equal="" to="" each="" other="" the="" string
posted="" by="" setwindowtext()=""> ,BUT
the caption of the textbox isn't the same as the value appears on it
<the value="" is="" nothing="" but="" the="" caption="" equal="" to="" string="" posted="" by=""
setwindowtext()="" function="">then i want an API function to set the value of the textbox not the
caption..
thank you very much for any help..
Sender :Amr abdel mohsen
Email: app_prog@yahoo.com
amr
|
|
|
|
|
You can also check for WM_SETTEXT Window Message
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
i get the handle of a textbox in an opened window using the function
EnumChildWindows(,,)..
after i obtained the handle of this textbox i want to set a specific
string in this textbox.
"HINT" : the function SetWindowText(,) isn't a valid to this task(why?)
more--->
the opened window has a textbox ,a button ,a label;
and when i used the spy++ program of Microsoft tools to get the caption
to each of them after using SetWindowtext(,),i observed that:
the caption of the label is same as the value appears on it<the
caption="" and="" value="" appears="" are="" equal="" to="" each="" other="" the="" string
posted="" by="" setwindowtext()=""> ,BUT
the caption of the textbox isn't the same as the value appears on it
<the value="" is="" nothing="" but="" the="" caption="" equal="" to="" string="" posted="" by=""
setwindowtext()="" function="">then i want an API function to set the value of the textbox not the
caption..
thank you very much for any help..
Sender :Amr abdel mohsen
Email: app_prog@yahoo.com
ÚãÑæ ÚÈÏ ÇáãÍÓä
|
|
|
|
|
Hi All
I am trying to include the inch symbol (ie " the same as a double quotation mark) in a function that requires a text string input between double quotation marks along the lines of: ?
SysAllocStringByteLen("Some text with the inch symbol" and then end",44)
How do I mark the " inch symbol so that it is not mistaken as the end of the text string
Regards
Jeremy
|
|
|
|
|
SysAllocStringByteLen("Some text with the inch symbol\" and then end",44)
|
|
|
|
|
Brilliant!! Many thanks for that!
|
|
|
|
|
I'm writting a function which send PostScript file directly to printer. Although it works, the paper is always the default size(A4).
To change paper size, I use SetPrinter(). But SetPrinter() need administrator privilege, and the printer is a shared printer of another computer in the network, which means no admin privilege can be got.
How to solve the problem f or setting paper size?
-------------------------------------------------------------------
PRINTER_DEFAULTS Defs;
PRINTER_INFO_2 *pPrnInfo2;
CPrintDialog dlg(TRUE);
DEVMODE *pDevMode;
CString szDeviceName;
HANDLE hPrinter;
DWORD dwNeeded;
if (dlg.DoModal() != IDOK) // select printer
return;
szDeviceName = dlg.GetDeviceName();
pDevMode = dlg.GetDevMode();
Defs.pDatatype = "RAW";
Defs.pDevMode = pDevMode;
Defs.DesiredAccess = PRINTER_ACCESS_USE; // if this, SetPrinter() failed
//Defs.DesiredAccess = PRINTER_ACCESS_ADMINISTER; // if this, OpenPrinter() failed
if (OpenPrinter((LPTSTR)(LPCTSTR)szDeviceName, &hPrinter, &Defs))
{
// Set Printer
GetPrinter(hPrinter, 2, 0, 0, &dwNeeded);
hGlobal = GlobalAlloc(GHND, dwNeeded);
pPrnInfo2 = (PRINTER_INFO_2 *)GlobalLock(hGlobal);
GetPrinter(hPrinter, 2, (LPBYTE)pPrnInfo2, dwNeeded, &dwNeeded);
pPrnInfo2->pDevMode->dmPaperSize = DMPAPER_A3;
if (!SetPrinter(hPrinter, 2, (LPBYTE)pPrnInfo2, 0))
TRACE("\n%d", GetLastError());
// Printing
DocInfo.pDocName = "EPS Document";
DocInfo.pOutputFile = NULL;
DocInfo.pDatatype = "RAW";
StartDocPrinter(hPrinter, 1, (LPBYTE)&DocInfo);
StartPagePrinter(hPrinter);
WritePrinter(hPrinter,....);
EndPagePrinter(hPrinter);
EndDocPrinter(hPrinter);
GlobalUnlock(hGlobal);
GlobalFree(hGlobal);
}
GlobalUnlock(pDevMode);
ClosePrinter(hPrinter);
|
|
|
|
|
For example i have written a program located on :
C:\..somewhere..\myprogram.exe
my problem is that i want to get the full path from where my program was launched.For example if my program is launched from C:\ProgramFiles\MyPrograms\Bin\myprogram.exe then i need to get this path.But i don't know how
Can anyone help ???
Regards,
m0n0
|
|
|
|
|
|
Thanks
m0n0
|
|
|
|
|
|
Thanks, it's really cool FAQ.
I found answer to a problem which mourned me for a long time i also wanted to do so that i was able to select full row in CListCtrl and it was explained here in one line , though i found many articles where this was achieved by writing several lines of code
m0n0
|
|
|
|
|
I am having a small problem using CRichEditCtrl on w9x (app built with VC6 sp6 on w2k). When I run the app on w2k, AfxInitRichEdit() loads RichEd32.dll which in turn loads RichEd20.dll that contains the code for version 3.0 of the rich edit control. But if I run the app on w98 the RichEd32.dll that gets loaded contains the code for version 1.0 of the rich edit control, and the control fails to be created. I tried to put the w2k copy of RichEd32 in the same folder as the app, but it does not get loaded, the app instead loads the older version found in the system directory. I had always had the understanding that the app would load the dll from the apps directory first before it went to the system directory, but apparently I was wrong on that. If I move the newer dll to the system directory, and remove the old dll, everything works great.
Question: Is it safe to redistribute the newer (v5) RichEd32.dll to w9x to replace the older (v4) dll that is already there? or is that just going to cause nothing but grief to other apps that may use the same dll? If I do that do I also have to redistribute RichEd20.dll? The RichEd dlls are not on the list of redistributable files that came with VC. I am guessing this is where the term "dll hell" comes from.
The only other option I can think of is not use MFC6's CRichEditCtrl, but to instead write my own wrapper that uses RichEd20.dll directly.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|