|
I'm trying to find a virtual listbox class but I can't seem to find one anywhere. I need to have a listbox with alot of values which takes too o\long to load in a regular listbox.
|
|
|
|
|
I'm having some problems with the heap..
First I create a new heap object:
m_phArray=new HTREEITEM[nSizeOfArray];
Then later I try to delete it, in a different virtual function:
delete[] m_phArray;
And after debugging I get:
memory check error at 0x016A0048 = 0xD8, should be 0xFD.
memory check error at 0x016A0049 = 0x21, should be 0xFD.
memory check error at 0x016A004A = 0x62, should be 0xFD.
memory check error at 0x016A004B = 0x00, should be 0xFD.
Is there a simple sollution to my problem, or an in depth web page on the Heap you could reference me to? Thanks.
-Templeton
|
|
|
|
|
this almost certainly means you've written a value off the end of the array. check every place you write a value into the array and make sure you're not going past the (nSizeOfArray-1)th element.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
it's not almost certainly; it is. Thank you, works like a charm.
-Templeton
|
|
|
|
|
Hi there,
What's the best way to show a HTML in the dialog ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
|
I have created MFC single document application
I want my application to support the winsocket .
if i typed in following code, I got errors eventhough i have included <windows.h> header file.
WSADATA wsda;
SOCKADDR_IN serverAddr;
SOCKET theSocket;
LPHOSTENT hostEntry;
int ws, conn, snd, rev;
char buffer[256];
how can i get window socket supporting for my current application without recreate a new project?
Thanks
|
|
|
|
|
If you tell us what the errors actually are, then we might be able to help you...
Dave
|
|
|
|
|
I am having a problem using print and printpreview in a FormView.
If I build using MFC as a shared dll, all works as it should.
If I build using MFC as a static library, I get an error when the print function tries to create the dialog to show print status. Apparently when
Create(CPrintingDialog::IDD, pParent);
gets called in the CPrintingDialog contructor,
if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE))<br />
{<br />
ASSERT(FALSE);
PostNcDestroy();
return FALSE;<br />
}
in CDialog::Create fails because there isn't a valid document template name. Is this the document template name of my form view or one created by MFC for the print dialog? How do I make sure it gets set? I need to compile using MFC as a static library due to installation on other Windows versions.
Ed
|
|
|
|
|
I want to set the transparency (SetLayeredWindowAttributes(...))of my dialog. One option is to LoadLibrary, i did, and it was successful.
But I want to do this the primitive way: Project>Setting>Link>Object/Library module
"C:\Program Files\Microsoft Visual Studio\VC98\Lib\User32.lib"
"C:/Program Files/Microsoft Visual Studio/VC98/Lib/User32.lib"
"User32.lib"
User32.lib (without quotation)
none worked. I didnt get any compiler error but the compiler does not recognise SetLayeredWindowAttributes(...) for one reason or another...
Help! feel like an idiot.
norm
|
|
|
|
|
If you want to use the lib file then you need the latest header files, you must download the lastest Platform SDK from http://MSDN.microsoft.com
Btw actually it's enough to include User32.lib (without quotation) to your project settings, although it should be included by default
modified 12-Sep-18 21:01pm.
|
|
|
|
|
i think u're right... i searched winuser.h and it's not even there.
and MSDN didnt mention that u need the latest version for this sh*t..
thanks anyway. got my hands on Platform SDK Build2601 August 2001 Edition.
norm
|
|
|
|
|
(Not 100% sure) Try definining the macros _WIN32_WINNT and WINVER as 0x0500 before any inclusion (or preferrably on the preprocessor editbox in the project settings).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanks!
but, is this what u mean?
#define _WIN32_WINNT
#define WINVER 0x0500
norm
|
|
|
|
|
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am still getting the error:
Compiling...
DeleteThisProjectDlg.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\DeleteThisProject\DeleteThisProjectDlg.cpp(123) : error C2065: 'SetLayeredWindowAttributes' : undeclared identifier
Error executing cl.exe.
I have already:
1. installed August 2001 Build 2601 SDK
2. #define _WIN32_WINNT 0x0500
#define WINVER 0x0500
3. #include "winuser.h"
4. import User32.lib
Project>Setting>Link>Object/Library Modules>
I've added User32.lib in the text box with NO QUOTATION MARK.
5. These are the only code i added to this simple MFC dialog app:
BOOL CDeleteThisProjectDlg::OnInitDialog()
{
...
... wizard generated code
...
// TODO: Add extra initialization here
# define LWA_COLORKEY 1
# define LWA_ALPHA 2
# define WS_EX_LAYERED 0x80000
SetWindowLong (this->m_hWnd, GWL_EXSTYLE, GetWindowLong (this->m_hWnd, GWL_EXSTYLE) |WS_EX_LAYERED/*|WS_EX_TOOLWINDOW*/ );
SetLayeredWindowAttributes(this->m_hWnd, RGB(0,0,0), 240, LWA_ALPHA); //QUESTION: Intellisence dont give you this API from the list?? ::SetLayeredWindowAttributes doesnt work neither?
...
...
...
return TRUE; // return TRUE unless you set the focus to a control
}
norm
|
|
|
|
|
Try defining the macros into the project settings, Go to Project->Settings->C/C++->Preprocessor definitions, and insert there the following
,_WIN32_WINNT=0x0500,WINVER=0x0500 Good luck!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Quote:
" Project->Settings->C/C++->Preprocessor definitions, and insert there the following,_WIN32_WINNT=0x0500,WINVER=0x0500"
just tried. didnt work unfortunately. THe compiler is still bitching that it doesnt understand SetLayeredWindowAttributes(..)
btw, #define precompiler directive does the same does it not?
I found on my machines that there's a total of four User32.lib:
1. C:\Program Files\Microsoft SDK\lib
2. C:\Program Files\Microsoft SDK\lib\IA64
3. C:\Program Files\Microsoft Visual Studio\VC98\Lib
4. C:\Program Files\Microsoft Visual Studio.NET\VC7\PlatformSDK\lib
I'm also suspecting that #include "winuser.h" is including the wrong version...
anyway, it's 5am here now. will get back to this tomorrow.
nite
norm
|
|
|
|
|
I have checked and there're three winuser.h on my system. So, I #include the version that has defined SetLayeredWindowAttribute as follows (dialog class cpp file):
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
#include "C:\Program Files\Microsoft SDK\Include\WinUser.h" //I double checked. SetLayeredWindowAttributes is declared in this file. For some strange reason, Intellisense doesnt seems to register this???
And I am still getting this compiler error:
Compiling...
DeleteThisProject.cpp
DeleteThisProjectDlg.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\DeleteThisProject\DeleteThisProjectDlg.cpp(128) : error C2065: 'SetLayeredWindowAttributes' : undeclared identifier
Generating Code...
Error executing cl.exe.
Since it's a compiler error, can I safely conclude that it has nothing to do with library file user32.lib? But how can this happen? I openned the header file and I search for the API and there it is the declaration of the API is sitting right in front of me: SetLayeredWindowsAttributes(..)
norm
|
|
|
|
|
How to output string into a file? My part of code is below:(Look at the last line, it is not ok.)
// Open the file ready write
if((pOutputFileStream = fopen(csFilePath, "w")) != NULL)
bStatus = TRUE;
// Otherwise output message to the console window.
else
{
printf("The output %s file is not available!", csFilePath);
bStatus = FALSE;
}
if (bStatus)
{
// STL string.
string str = vNode.back ();
cout << str << endl;
//
// this line is not ok.
//
fprintf(pOutputFileStream, "%s", str.substr);
}
Thanks.
mIchAel Liu
__________________________________________________________
The secret of business is to know something that nobody else knows.
|
|
|
|
|
Use C++ instead of C. Longer reply in ATL/WTL/STL.
I should add that if you're stuck with C files, you can use the c_str() function of a std::string to get a const char *.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
??
Is it bad to do a SendMessage() to the main application from a UI thread? Does the thread hang until a response is made? Could I get deadlocks etc..
|
|
|
|
|
SendMessage() sends a message to the target window synchronously - i.e. it waits for the message to be processed before returning. Consequently, it is inherently dangerous to use SendMessage() to send messages between threads. It blocks the sending thread until the message is processed, and so if the target thread then does something that requires a response from the first thread, deadlock will occur. It is possible to design your application in such a way to ensure this will not happen, but it is generally not the preferred option. Generally you should use PostMessage() or PostThreadMessage() to communicate betweeen UI threads.
Dave
|
|
|
|
|
The reason I ask is because I was using PostMessage but the thread would exit before the lParam value (CString) could be read by the main app.. I assumed that if I used SendMessage the UI thread would wait until the main app read the message..
|
|
|
|
|
You should create the CString (or whatever data structure) on the heap instead:
CString* pStrResponse = new CString( "My string" );
if ( !::PostThreadMessage( dwMainThread, myResponseThreadMessage, wParam, reinterpret_cast<LPARAM>( pStrResponse ) ) )
delete pStrResponse; // Only delete it if the post failed
Then in the main thread
LRESULT CMyApp::OnThreadResponse(WPARAM wParam, LPARAM lParam)
{
CString* pStr = NULL;
try
{
pStr = reinterpret_cast<CString*>( lParam );
// Do something with it
}
catch ( ... )
{
ASSERT( FALSE );
}
delete pStr; // Make sure we delete this even if an exception occurs
}
Dave
|
|
|
|