|
yashraj1215 wrote:
2) What is TCHAR?
It is a Win32 character string data type that can be used to describe ANSI, DBCS, or Unicode strings.
|
|
|
|
|
1. not automatically, but using static_cast or old C cast. The idea here is that any datatype could be treated as array of bytes in memory (arguably smallest unit allowed in C++) example "int" datatype occupies exactly the same space in memory as "unsigned char[4]". It is more convention than a rule of C/C++.
2. TCHAR is a Windows convention when you compile ANSI it converts to "char" (1 byte), when you compile UNICODE it compile it converts to wchar_t (2 bytes). Therefore, when you deal with string sizes in bytes it is important to remember size of the basic unit (1 or 2 bytes)
|
|
|
|
|
yashraj1215 wrote:
I do not understand what purpose "(LPBYTE)" serves in this code; the code will not compile without it. I found "(LPBYTE)" in the MSDN library, but it never explained what it does or what it means... does anyone know?
While you did not indicate, I would imagine you have mycaption defined as a char, rather than a BYTE. For example, using:
LPBYTE mycaption = "Some Caption Here";
or
BYTE mycaption[32] = "Some Caption Here";
you could have called RegSetValueEx() like:
RegSetValueEx(hKey, TEXT("LegalNoticeCaption"), 0, REG_SZ, mycaption, _tcslen(mycaption) * sizeof(TCHAR));
yashraj1215 wrote:
The last parameter of the RegSetValueEx function is supposed to be the size of the buffer. Is the buffer size equal to one byte per character?
Yes, unless you are dealing with DBCS (i.e., Unicode). In that case, every character uses two bytes.
yashraj1215 wrote:
What is the difference between a signed char, an unsigned char, and a char? What are their individual purposes?
A char and signed char are the same thing (i.e., they use the sign bit). If a type does not have the unsigned qualifier, it is assumed signed.
yashraj1215 wrote:
What are their individual purposes?
It actually depends on what you are storing. ASCII characters (0-127) can be stored in a char, whereas extended ASCII (0-255) must use an unsigned char.
|
|
|
|
|
um, i was thinking of writing a server for something and suddenly something bothered me, like this:
If you have a router between your network and the internet that has a built in firewall, and you have lets say.. port 3000 open, and someone tries to establish a tcp connection with your computer on the network... a syn packet will be sent to the ip address of your internet connection, so it arrives at the router, and the router sees its destined for port 3000 and lets it pass..but then, what if two computers on the network both have their port 3000 listening.. how does it know which should reply, or for what computer the connection was ment???? I'm sure the sollution is pretty simple but i just couldn't think of it, and its bugging me.
Kuniva
--------------------------------------------
|
|
|
|
|
You have to explicity tell the router that an incoming port 3000 get routed to port 3000 on that computer. If you make a connection outbound, then there is information there to route the response back to you. It can't magically determine where an inbound port is routed to.
Joel Lucsy
|
|
|
|
|
Standard port forwarding...
onwards and upwards...
|
|
|
|
|
erm...right. But the thing is, our router uses DHCP, so one time my PC will have this ip, the other it will get another assigned. So you see, i can't specify a forewarding ip address.... (btw i'm not administering our router due to technical restrictions, otherwise i'd know all this)
Kuniva
--------------------------------------------
|
|
|
|
|
You might be able to specify the routing based on mac address. Don't know of any router that did this, but then again, I've only dealt with fairly cheap ones.
Joel Lucsy
|
|
|
|
|
Usually the firewall will allow you to specify a forwarding address. So if you want all connections to port 3000 on your router to be sent to an internal host you would configure the router to forward to a specific internal IP address. When the request comes in to the router, the router routes it to the specified internal address.
Each host has only one IP address, so only one host will get the packet. Now you could of course configure it to be forwarded to the broadcast address and this would mean each host recieves the packet. This could be ugly though.
--
"The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed."
-- Abraham Lincoln
|
|
|
|
|
I have a CFormview based SDI application. On the formview, I have a property sheet displayed, which has quite some edit controls.
Although I have specified accelerator keys in the resource, the program never respond to any key press. So I am thinking of CMyView::PreTranslateMessage, then CMyView::WindowProc, but neither of them can capture wm_char message when I pressed any key when the edit control on property page is having the input focus.
what can I do? Thanks a lot!
|
|
|
|
|
It's just a guess, i don't use the MFC framework, but don't the WM_CHAR messages only get sent to the actual edit window?
Try using GetWindow() to get the handle of the edit control, and then run a loop using GetMessage() to get the first message in the message queu. Then check it for WM_CHAR and ...
It's just a guess though, there's probably an easier way
Kuniva
--------------------------------------------
|
|
|
|
|
I am not sure. But in one article Nish wrote, you can use PreTranslateMessage to capture wm_keydown or other messages by the dialog instead of having it processed by the control which have the input focus.
I think I should be able to do the same in my app. but
The GetWindow() would be a messy one in my case even it works, since I have hundreds of edit controls.
any other hint?
|
|
|
|
|
Hi,
I am developing a Application which communicated with a Wireless
Protocol Stack on board,
through Serial Communication from a Windows XP m/c. through PPP packets. I
am using MFC API's
for sending data. Is there any mechanism to find out what actual data is
been sent through the COM port
and which protocol is used in sending. I mean the format of the data packets
and so..
Please respond soonly and it would be a great help for me..
Thanks,
pramodav@sasken.com
Pramod Kumar A
SASKEN-INDIA
|
|
|
|
|
Hi
I want to know the physical size of my monitor in inches/millimeters/centimeters. This is what I do currently:
CDC dcDisplay;
if(!dcDisplay.CreateDC("DISPLAY", NULL, NULL, NULL))
{
MessageBox("Failed to get display DC.", "Error", MB_OK|MB_ICONEXCLAMATION);
ExitProcess(0);
}
int xDPI = dcDisplay.GetDeviceCaps(LOGPIXELSX);
int yDPI = dcDisplay.GetDeviceCaps(LOGPIXELSY);
int xRes = dcDisplay.GetDeviceCaps(HORZRES);
int yRes = dcDisplay.GetDeviceCaps(VERTRES);
int xInches = xRes / xDPI;
int yInches = yRes / yDPI;
const double dInchToMillimeter = 25.4;
double xMillimeter = xInches * dInchToMillimeter;
double yMillimeter = yInches * dInchToMillimeter;
So I get 13 Inches horizontal (330,2 mm) and 10 Inches vertical (254 mm).
But there's another method, that outputs something different:
int xMillimeter = dcDisplay.GetDeviceCaps(HORZSIZE);
int yMillimeter = dcDisplay.GetDeviceCaps(VERTSIZE);
Outputs 320 mm horizontal and 240 millimeters vertical.
Which method is more trustful? One more thing: If I measure
my display with a ruler it seems that all values determined by both functions are too small, e.g. it seems that my display has a width of at least 350 mm and a height of at least 260 mm
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
From what I understand of it, there is no really accurate way to determine the monitor size.
|
|
|
|
|
Windows assumes the monitor's resolution is 96dpi. There's no way that your program can accurately work out how big the monitor is, unless you look in the registry for the monitor model and lookup a database...
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I have a Dialog project that when compiled will only show the MFC Icon with Windows Explorer. If you click on the file and display properties, then the Icon displayed is the one that I created for it.
Any suggestions as to what I am doing wrong.
Thanks in advance.
Eldon Zacek
Czech-Mate Enterprises, LLC
|
|
|
|
|
Change both the 32x32 sized icon AND the 16x16 and your problem may be fixed.
-KMAZ
|
|
|
|
|
In the VC++ icon editor, there are several available icon types. The one that is normally displayed with your app is the 32x32 size but a second one is also created by default of size 16x16. Explorer usually uses the smaller one. To fix your problem, redraw the smaller one too and rebuild your app.
I am always doing this myself too.
|
|
|
|
|
You have to make sure that there is a 16x16 icon in the icon itsef. Open the icon in Visual Studio and make sure there is a 16x16 version of the icon.
Regards,
Brian Dela
|
|
|
|
|
I want to do the same that MFC do when the New Document option in Menu is pressed.
What I have to call?
I've tried Doc->OnNewDocument() but is not the same, because the view is not refreshed. I think the call has to be related to OnFileNew of app but I don't know what's the correct sintaxis.
Best Regards
Dr.Pi
|
|
|
|
|
How about the following:
AfxGetMainWnd()->PostMessage(WM_COMMAND,ID_FILE_NEW);
|
|
|
|
|
|
I have a problem at the middle of my work. I don't want to restart from the beginning.
Right now, I am writting a software in C++ with MFC. I use the Message MAP builded by the Wizard. I don't want to tell what kind of software I do because it is confidential. This is a tool used on PC, which communicate with an embedded system.
I don't need a real time software, the time is not critical. We also want something friendly. That is why my interface is Window. At this time, everything work, for the futur, I see a problem.
The problem is the following:
-----------------------------
When a process is currently running (not finish), I want to exit from my function, do something else, and come back to see if I have the result of that process or exit if the timeout is elapsed. To do so, I need to Dispatch the Message
by myself like the old method with the Windows Procedure and the switch case with different messages. I know very well how to do it but now, I have a software with a message map. Bad or good decision, I am not sure at this time.
My solution is to restart a new project with old fashion and control all message with the switch case (no message map). I can also recuperate all my files.
Other problem, the old method use HANDLE, MFC doesn't.
Is there something I don't understand ????
Please, help !
Danny
|
|
|
|
|
MFC map is the switch statment just add your message to it
|
|
|
|