|
If I want to create a new thread in my code & run it in Debug Mode what are the visual C settings?
--> C/C++ Code Generation : DEBUG_MULTITHREADED ... should be all
Can I create this in a Console App, should it be Debug Multithreaded ?
--> YES and IT MUST BE MULTITHREADED!
My code compiles, but the new thread never kicks in when I run it??? Any help appreciated...
--> CAN`T SEE THE CODE! This can have a lot of reasons - maybe your thread never gets an object it is waiting for .... Do you use any WaitFor..() functions ???
Greatings Mario ///
Greatings Mario ///
----------------------
www.klangwerker.de
mario@klangwerker.de
----------------------
|
|
|
|
|
Have any idea about how to invoke a context menu on right
click of Network Neighborhood computer. Say u want to display two menu
items like connect and disconnect of a n/w neighborhood computer using
ShellExtensions.
Any idea or suggestions highly appreciated..
Pls. provide how to register the component , i mean under what hive to be
registered.
Thanks & Regards,
soma
![Roll eyes | :rolleyes:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_rolleyes.gif)
|
|
|
|
|
I found that there are some memory leaks when running it in NT.
Here are the source codes.
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
typedef struct DATA
{
char *data;
DATA *next;
} DATA;
void test2(DATA *d)
{
if (NULL == d->data) {
d->data = new char [100000];
if (NULL == d->data) {
printf("No memory for d->data.");
return;
}
}
else {
DATA *dp = d;
while (dp->next != NULL) dp = dp->next;
dp->next = new DATA;
if (NULL == dp->next) {
printf("No memory for dp->next.");
return;
}
memset(dp->next, 0, sizeof (DATA));
dp->next->data = new char [100000];
if (NULL == dp->next->data) {
printf("No memory for dp->next->data.");
return;
}
}
}
void main(void)
{
printf("Press ENTER to start.\n");
_getch();
int i;
DATA d, *dp, *next;
memset(&d, 0, sizeof (DATA));
for (i = 0; i < 200; i++) {
test2(&d);
test2(&d);
test2(&d);
test2(&d);
test2(&d);
}
printf("Press ENTER to continue.\n");
_getch();
delete[] d.data;
dp = d.next;
i = 1;
while (dp != NULL) {
next = dp->next;
delete[] dp->data;
delete dp;
dp = next;
i++;
}
printf("i = %d.\n", i); // 1000 expected.
printf("Press ENTER to finish.\n");
_getch();
}
Pls help...;)
|
|
|
|
|
I found out this mysterious memory leak too, but I am really puzzled because my testing program can't be simpler (see below). I used VC++6/SP4 to compile it and checked it with MemCheck 5.0. The latter said "no HeapFree for HeapAlloc" four times and "no HeapDestroy for HeapCreate". I am not even using the new and delete operators, but why is the program calling HeapAlloc and HeapCreate AND not calling HeapFree and HeapDestroy to clean up the mess?
#include "stdafx.h"
#include <stdio.h>
void main(void)
{
char c;
printf("Test to see if there is memory leak...\n");
c = (char) getchar();
printf("The character is %c.\n", c);
}
|
|
|
|
|
Well... the c lib is calling the HeapAlloc/HeapCreate for internal data, but since that data needs to be allocated for all live of your program there is no need for calling HeapDestroy/HeapFree. When your program ends the OS automatically frees all the memory that has been allocated by you (in this case by the c lib) so there is no leak at all...
Bye,
Rui Lopes
|
|
|
|
|
I want to implement refresh, back and forward buttons in my browser!! how can i do this?
Please help. I would also like to impement an favourites button or something like that.
THANKS!!!!!
DAMION
|
|
|
|
|
Could I have some example code for C++ MFC to create and display a simple property sheet, or Tabbed dialog box, with the Tabs positioned along the bottom please?
Thanks
David
|
|
|
|
|
Use the TCS_BOTTOM style wich is defined in CommCtrl.h (line 5067 in my version).
With the best regards, Vitaly.
|
|
|
|
|
My program has some property settings and so i make a dialog box with some textboxes and checkboxes to display all those settings. I allow the user to change the settings and save them. I want to update the Dialog view when the user click the checkbox. For example, there are 8 checkboxes represent 8 bit binary number and there is a textbox to represent this 8-bit binary in hex number. I want the textbox display the most updated binary information from those 8 checkboxes.
So, I send message to the dialog when the user "click" the checkbox. However, i don't know how to update the Dialog box so that it can update the textbox.....
Can anyone help me?
|
|
|
|
|
Invalidate(false) redraws a window ( which both the text box and dialog box are ) without erasing the background first, thus avoiding flicker. Invalidate(true) erases the background first.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
I think you want CWnd::UpdateData().
|
|
|
|
|
Dear all,
How can I pass the string in a char array or CString array in this Speak() function?
e.g. char chararray[5][5];
chararray[0] = "Hello";
or
CString cstringarray[5][5];
cstringarray[0] = "How are you";
HRESULT Speak (PCWSTR pszSpeak);
Since the parameter should be a pointer of WCHAR, do anyone know how to convert the string to the suitable parameter?
Looking forward to your sincere reply. Thanks a lot!
|
|
|
|
|
Vickie,
usually when I write applications I decide to either use wide characters (Unicode) strings everywhere or to use normal characters thus avoiding problems like yours. But I have had the same problem you are having numerous times. There are two ways that I have used to convert plain old char arrays to wide characters:
1. Windows provides two API calls to help things along:
WideCharToMultiByte and MultiByteToWideChar these functions take quite a few parameters and can be quite cumbersome to use.
2. Use wcstombs and mbstowcs (this is the method I prefere). Look them up in your doco but this will give you an idea:
char mBuf[255];
wchar_t wBuf[255];
i = mbstowcs( bBuf, mBuf, 255 );
hope this helps
Accept that some days you are the pigeon and some days the statue.
|
|
|
|
|
ummm
is the app a unicode (or wide char) app? if so all your strings will be wide char so passing a string ptr is as easy as Speak(szString) or Speak ((LPCTSTR)csString)
if the app isnt unicode then u have to use the conversion macros
USES_CONVERSION;
W2A(blah blah blah)
A2W(blee blee blee)
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
<<< In the name of GOD >>>
Hi.
I want to display icon inside the text in ListBox
in VC++, but i don't know how can i use of WM_DRAWITEM
message and DRAWITEMSTRUCT structure.
Please help me ...
Thanks.
Hadi Rezaie
|
|
|
|
|
Take a look at CComboBoxEx. Just define an image list using SetImageList() and then select the desired image when you add an entry. Voila.
|
|
|
|
|
I compile my (any) WTL Project with following settings:
Project/Settings/C++/Calling Convension: __stdcall.
In release configuration I'm forcedly compile with Debug Run-time library (instead release lib; Project/Settings/C++/Use run-time library),
else : "The instruction at ... referenced memory at ... . Memory could not be read" - with any release lib - single threaded, multithreaded, multithreaded DLL.
Thanx for any help.
|
|
|
|
|
Hi,
I've got to develop a snap-in for the Microsoft Management Console (mmc). I dont have documentation to do that. If someone have a link or an example to help me it would be very apreciate. I usually seen the msdn documentation but it's not very clear in my head and I have trouble with the example.
Thanx for helping me !!!
|
|
|
|
|
I've wrote one...
If it's still actuelle, write me - reznitskiy@softlab.ru
|
|
|
|
|
The Microsoft Platform SDK has numerous code samples for Snap-ins.
|
|
|
|
|
The context menu is simply popup by right clicking the mouse. That's the system default that I don't want it.
|
|
|
|
|
subclass it and trap the right mouse click event and do nothing in it
seems the easiest way to me
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
As we all know, forward declarations are necesary to implement circular references, like below:
struct A;
struct B
{
A * a;
};
struct A
{
B * b
};
My problem is, how do i deal with this using templates? The following pice of code is a syntax error in VC++ 6.0:
template<class c="">
struct A;
template<class c="">
struct B
{
A<c> * a;
};
template<class c="">
struct A
{
B<c> * b
};
Does anyone know th correct syntax?
Jonas Pettersson
|
|
|
|
|
Hmm, this discussion group does not seem to support brackets, they didn't get posted. I'll re-write the question using parenthesis as brackets...
------------------------------------------------------------------------------------------
As we all know, forward declarations are necesary to implement circular references, like below:
struct A;
struct B
{
A * a;
};
struct A
{
B * b
};
My problem is, how do i deal with this using templates? The following pice of code is a syntax error in VC++ 6.0:
template(class C)
struct A;
template(class C)
struct B
{
A(C) * a;
};
template(class C)
struct A
{
B(C) * b
};
Jonas
|
|
|
|
|
I don't get template-related syntax errors when compiling the code in VC6 after simply changing the parentheses to brackets...there is a missing semi-colon after B<c>* b in struct A, but other than that, no problems. (I'm able to create instances of the structs, too; link and running is no problem.)
Walter Gildersleeve
Freiburg, Germany
walter.gildersleeve@pe-gmbh.de
|
|
|
|