|
Use the resource editor in VC++.NET to create an icon, having it as a named resource in your project. Then in your dialog's OnInitDialog() function, type (replace IDI_DIALOG with the name of your icon's resource name.):
[...]
HICON hicon = AfxGetApp()->LoadIcon(IDI_DIALOG);
ASSERT(hicon != NULL);
SetIcon(hicon, TRUE);
[...].
Happy Programming and God Bless!
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
Using VS 2003, MFC 7.1, when creating a property sheet the internal CPropertySheet::OnInitDialog() will create an exception, an access violation writing a location. This is observed in the VS debug output window, and surrounding the OnInitDialog call with some TRACE statements will prove where it's coming from.
I have experimented by creating the simplest apps with CPropertySheets I can imagine, and the exception always occurs. True for both static and dynamic MFC linking, various runtimes, etc.
Any suggestions? Has anyone else seen this also?
Richard
|
|
|
|
|
Hi i assume you fixed the problem . can you give me suggestion
|
|
|
|
|
Off and on for some time I've tried to find the best way to bring a window (whose parent is the desktop) to the top of all the other application windows on some particular event. They could very well be using another application window at the time so I can't allow it to take the focus away as this could result in lost keystrokes. My current implementation of this is basically the following:
HWND hwnd = ::GetForegroundWindow();
::SetWindowPos(myhwnd, hwnd, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
::SetWindowPos(myhwnd, hwnd, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
I've investigated numerous other ways over time. This works well but doesn't always work perfectly. Some times focus is stolen and sometimes the z-order isn't correct. These are rare cases and usually involve some specific other application that was in use at the time.
I'm wondering if anyone could offer solutions they've tested and used in the past for performing something similar?
Craig
|
|
|
|
|
Sorry, I meant to code it:
HWND hwnd = ::GetForegroundWindow();
::SetWindowPos(myhwnd, hwnd, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
::SetWindowPos(hwnd, myhwnd, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
|
|
|
|
|
How to concatenate a string and an int
|
|
|
|
|
There are many ways. It depends of type of your string. For null-terminated const char * you can use this one:
char res[128];
const char *str = "Result is: ";
int num = 10;
sprintf(res, "%s%d", str, num);
---
Realtime 3D screensavers
|
|
|
|
|
well a solution would be this one:
int x=466;
char conc[1024];
_itoa(x,conc,10); //converts the int to string now conc="466"
strcat(conc," is a converted number");
//now conc is "466 is a converted number"
Hope this is what you want
gabby
|
|
|
|
|
unresolved external symbol "public: __thiscall CMyProcessesInfo::CMyProcessesInfo(class CWnd *)" (??0CMyProcessesInfo@@QAE@PAVCWnd@@@Z)
|
|
|
|
|
|
I have a project and am hoping for input on how I might further consider the feasability of using C++ to implement it. My main problem is that I am only slightly familiar with visual C++.
Project Details:
(1) Embedded device reads data every 4 seconds and transmits a UDP paket to a Server.
(2) C++ application gets packet, pulls out info, and updates MSSQL database.
(3) Web browser loads page and constantly updates the current value for viewing purposes, and other application access the data directly from the database.
So, Step (1) and (3) are no problem. My question involves (2). I will be using visual c++ 6.0.
The only experience I have had with Visual C++ is to take and existing application and make modifications to it basically using examples that were in the code already. I have 3 questions below that are all: "How do I do that?" What I am getting at is what libraries and functions I use to get the functionality, or the correct terminolgy so that I can find some sort of help on each separate topic.
This is an application that must be running continuously, can or should it run as a service? How do I do that? Is it worth the effort that might be involved versus just dropping the exe into the startup folder?
The application must be set up to listen for udp packets on a certain port. How do I do that?
Once I have the packet I will need to yank out the data and do an SQL update. How do I do that? I am familiar with using ADO in ASP pages, is it similar to use in C++?
Any help whatsoever is greatly appreciated. Links to other online material that answer it for me or the names of the libraries and functions that I would use, or anything else that might help is what I think I am looking for.
Thanks for you help!
Brian
|
|
|
|
|
brian2222 wrote:
can or should it run as a service?
Yes
brian2222 wrote:
How do I do that?
http://www.codeproject.com/system/serviceskeleton.asp[^]
brian2222 wrote:
The application must be set up to listen for udp packets on a certain port. How do I do that?
You learn about "Socket" development. It's no small subject and will take some time.
brian2222 wrote:
I am familiar with using ADO in ASP pages, is it similar to use in C++?
The ADO COM interface is of course exactly the same. Working with COM in C++ is going to be very different than in script code or VB. So you have a learning curve there as well. I suggest looking at using the #import statement and the ATL smart pointer templates.
Good luck
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Anybody out there know a reasonably straight-forward way to save modified CBitmaps??
|
|
|
|
|
i need to extract the data to form a Tree ,i must transfer the cstring into char*
i use (lpstr) but compile note not well
so i myself write a function as following:
char* CSelectDlg::change(CString mystr)
{ int len=mystr.GetLength();
char* array=new char(len);
for(int i=0;i
|
|
|
|
|
CString str;
const char *cp = (LPCSTR) str;
char *p = (LPSTR) ((LPCSTR) str);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
I was not kidding at all. The link you provided is not http. Want to try again?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
CString str;<br />
const char *cp = (LPCSTR) str;<br />
char *p = (LPSTR) ((LPCSTR) str);
Truth be told, he answered the Original Poster's question perfectly. The OP did not ask if it was safe or even a good idea to cast a CString into a non-const char* ...! (Which, of course, we all know is generally not a good idea at all!)
Peace!
-=- James
Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
hi:your advice is ok by tring ,but can you explain why my method has some bug?
in addition i seldom have conscious to use LPCSTR LPSTR LPSTR , Please you give me a simple introduction about when to use them ?
thx again
|
|
|
|
|
There are only two ways of getting at the internal CString buffer. One is to use the LPCSTR operator and the other is to use the GetBuffer() method. One is read-only while the other is writeable. Since you did not indicate a need to update the buffer, I provided you with the LPCSTR way.
vividtang wrote:
i seldom have conscious to use LPCSTR LPSTR LPSTR
I do not understand this. Do you mean you seldom have a need to use them?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
vividtang wrote:
in addition i seldom have conscious to use LPCSTR LPSTR LPSTR , Please you give me a simple introduction about when to use them ?
Use them all the time ! MFC does
|
|
|
|
|
int len=mystr.GetLength() + 1;
char* array=new char(len);
lstrcpy(array, mystr);
or
CString s( "abcd" );
LPTSTR p = s.GetBuffer( 10 );
strcpy( p, "Hello" );
s.ReleaseBuffer( );
|
|
|
|
|
CString s( "abcd" );<br />
LPTSTR p = s.GetBuffer( 10 );<br />
strcpy( p, "Hello" );
ReleaseBuffer( );
Yes, yet another bad example from MSDN! No enforcement of the buffer size obtained (should have used strncpy(...) ), and no exception handling for example.
IOW, typical high-quality MSDN documentation/examples that newer developers can learn all kinds of bad habits from!
Peace!
-=- James
Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
James R. Twine wrote:
Yes, yet another bad example from MSDN!
A problem that they have acknoledged in MSDN Magazine Editors Note i believe. The site is huge with years of information built up. They are addressing the issue. Until then you can find newer resources there if you try.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsecure/html/strsafe.asp[^]
James R. Twine wrote:
typical high-quality MSDN documentation/examples that newer developers can learn all kinds of bad habits from!
Please point us to the more complete more correct online resource that we should be using instead of MSDN
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|