|
I agree with you.
Was just trying to answer a question I felt was a novice one, thats all.
I really do respect your knowledge!
Bikram Singh
|
|
|
|
|
bikram singh wrote:
If a has more than one \0 character, your method would not work.
but you do agree, this statement was intended for a "more knowledgable" audience, dont you?
You must have been in a hurry while replying, cos given your knowledge, you would have mentioned the words "unicode" and "ansi"!
I really do appreciate your knowledge!
Bikram Singh
|
|
|
|
|
In my program in VC++, i call functions that are defined in another machine.
When i debug my program (i.e. i go step by step by pressing f10) when i get to some of those extern functions, strange things happen: The debugger jumps many lines and it never stops in the extern functions. I cant ever put a break point in those lines!
Whats happening? Is anything i could do?
|
|
|
|
|
Seems like your linking against a release version of the library that is on the other machine
You need to build on that machine a debug version and link to it.
Or debug on the assembly level
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
mufasa2 wrote:
In my program in VC++, i call functions that are defined in another machine.
You have code on one machine that is using code on another machine. Is that correct? Are these other functions exported in some DLL? Are you explicitly or implicitly linking with this DLL?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Im the opposite of an informatic expert, so i will try to describe my best.
I have a controller simulator program that runs in a SGI machine.
I have a prog in C++ in a windows machine. this prog has a project which is a static library. This project has to call functions of the controller simulator.
In the project properties, in "libraries generation/other dependances" i input two libraries statiques of the simulator (like one example i have that makes use of the simulator).
I also declared a environement variable which makes reference to a file named "site".
"site" has information of the machine of the simulator: IP, port number. Thats how the connections are made (i follow also the same example as before)
|
|
|
|
|
Hello ,
I have a dialog based application.
On a menu command I need to hide sone controls (edit box and buttons) and I can do it (setting as not visible)
Now I need to resize the main dialog, since there is an empty area.
I tried with this (IDD_TEST_GUI_DIALOG is the ID of the main dialog window):
CWnd* pWnd = GetDlgItem(IDD_TEST_GUI_DIALOG);
RECT rc;
pWnd->GetWindowRect(&rc);
rc.right -= 100;
ScreenToClient(&rc);
pWnd->MoveWindow(&rc);
but I get an error.
If, instead of IDD_TEST_GUI_DIALOG, I put the ID of any other child element the function works.
What did I do wrong?
In debugging I find that, after GetDlgItem pWnd is 00000
Thanks in advance
Marco.
|
|
|
|
|
for some reason it's not possible to do a GetDlgItem on a dialog (IDD_...)
You can however, resize and shift your controls in your dialog.
Maybe that's a solution?
Their is a way to resize your dialog, but I have no idea on how. Is there no article about this?
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
Why do you try to get a pointer to your own class?
Try this code:
GetWindowRect(&rc);
rc.right -= 100;
ScreenToClient(&rc);
MoveWindow(&rc);
|
|
|
|
|
Hi
I have some questions regarding C++ basic types:
1. Is DWORD the same as unsigned long?
2. What's the difference between BOOL in VC++ and bool in C++? It seems that they're functionally identical, so why the redundancy?
Thanks!
|
|
|
|
|
DWORD I'm not shure. (I think it's 32bit data which can be interpreted as something else then a integer)
BOOL: 0,1 or 2,3,4,... (TRUE is defined as 1 and FALSE as 0)
bool: true or false, this cannot be a number, but is a boolean, a BOOL can be an integer value.
hope it helps.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
typedef unsigned long ULONG
typedef ULONG DWORD
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Indrawati wrote:
2. What's the difference between BOOL in VC++ and bool in C++? It seems that they're functionally identical, so why the redundancy?
VC++ creates a layer between native types and data types used in the VC++, BOOL is same as bool in windows, may be it will be different in the future release of VC++ or depending on the platform.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Mr.Prakash wrote:
BOOL is same as bool in windows
How so? One is 4 bytes while the other is 1 byte.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
bool is a C++ native type for boolean values whereas BOOL is merely a typedef for int
since C/ C++ treat int values as boolean. The benefit could be in performance etc. for e.g. if
you try to assign int to a bool you get this warning:
Compiler Warning (level 3) C4800
'type' : forcing value to bool 'true' or 'false' (performance warning)
DWORD etc are portable datatypes defined in Windows SDK. You can find a part of
the list in MSDN Library help.
BOOL A Boolean value.
BSTR A 32-bit character pointer.
BYTE An 8-bit integer that is not signed.
COLORREF A 32-bit value used as a color value.
DWORD A 32-bit unsigned integer or the address of a segment and its associated offset.
LONG A 32-bit signed integer.
LPARAM A 32-bit value passed as a parameter to a window procedure or callback function.
LPCSTR A 32-bit pointer to a constant character string.
LPSTR A 32-bit pointer to a character string.
LPCTSTR A 32-bit pointer to a constant character string that is portable for Unicode and DBCS.
LPTSTR A 32-bit pointer to a character string that is portable for Unicode and DBCS.
LPVOID A 32-bit pointer to an unspecified type.
LRESULT A 32-bit value returned from a window procedure or callback function.
UINT A 16-bit unsigned integer on Windows versions 3.0 and 3.1; a 32-bit unsigned integer on Win32.
WNDPROC A 32-bit pointer to a window procedure.
WORD A 16-bit unsigned integer.
WPARAM A value passed as a parameter to a window procedure or callback function: 16 bits on Windows versions 3.0 and 3.1; 32 bits on Win32.
Due Regards
Mahendra
|
|
|
|
|
Indrawati wrote:
2. What's the difference between BOOL in VC++ and bool in C++? It seems that they're functionally identical, so why the redundancy?
A tidbit from MSDN:
In Visual C++4.2, the Standard C++ header files contained a typedef that equated bool with int. In Visual C++ 5.0 and later, bool is implemented as a built-in type with a size of 1 byte. That means that for Visual C++ 5.0 and later, sizeof(bool) yields 1.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi all
I recently got a 3.4GHz P4 with HyperThreading (HT). I am getting weird things happening with my threads in my Visual Studio 6 C++ app. I have found that my mutexes are often ignored. This means that the data that the mutexes are protecting becomes invalid causing a GPF.
Example files:
class CBob
{
...
void Func();
CStringList m_listFiles;
CMutex m_mutex;
...
};
void CBob::DisplayFiles()
{
CSingleLock sLock(&m_mutex);
if (sLock.Lock(9000))
{
for (POSITION pos = m_listFiles.GetStartPosition(); pos; )
{
CString strFile = m_listFiles.GetNext(pos);
TRACE(strFile + "\n");
}
sLock.Unlock();
}
else
{
ASSERT(FALSE); //Mutex timeout
}
}
This only happens when I am running in Debug mode with HT enabled. Release mode does not crash even with HT enabled.
Has anyone got any ideas about why enabling hyperthreading causes the mutex to be ignored?
Cheers
Tha d3m0n
|
|
|
|
|
If there are multiple instances of CBob then the mutex must be declared static so the same instance is used by all instances of CBob. Are there multiple instances of CBob?
Also you should be able to use a critical section instead of a mutex, but that is an aside.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
There is only ever one instance of CBob.
I have looked everywhere I can think of for someone with a similar query but I haven't had any luck.
Do you think CriticalSection would be any more robust than CMutex?
|
|
|
|
|
[d3m0n] wrote:
There is only ever one instance of CBob.
I have looked everywhere I can think of for someone with a similar query but I haven't had any luck.
Do you think CriticalSection would be any more robust than CMutex?
How do you know the mutex is causing this problem? If there is only ever one instance of CBob then I suspect something else wrong.
A Mutex and CS should give the same results, however a CS is faster. Mutex's are typically used where you need to protect something across multiple processes, which you aren't doing from what I see.
I am aware of multi-threading problems which show up on multiple cpu pc's that don't show on single cpu machines.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
"How do you know the mutex is causing this problem?"
I know this because the program crashes in the for loop which iterates through every file in the list. If at that point I look at the value of the list, it is full of garbage.
As the only place which modifies the list is on a separate thread, which is also protected by the same mutex, I cannot figure out why the HT-enabled version is allowing the list to be changed whilst it is being looped through.
|
|
|
|
|
I want to try to use the vectorization to improve the performances of my programs, but I don't have too much information about how to use the libraries. Do you know what are the libraries (if there is any) I need to include to be able to use the types like 'vector int' or whatever? If there is not do I have to use intrinsics or there is another way?
thanks
Pierre
|
|
|
|
|
You should:
#include <vector>
and initialization of a vector of ints look like this:
std::vector<int> vInt;
or
std::vector<int> vInt(numElements, initialValue);
For other data types, just replace <int> with <name_of_data_type>
|
|
|
|
|
Note if you want to improve performance consider this.
If you are removing entries within the vector frequently then this is a "slow" process. It calls copy constructors for all entries above the deleted item as it shuffles them down.
Consider using list instead in these cases.
i.e.
#include <list><br />
<br />
typedef std::list<int> TIntList;<br />
<br />
TIntList m_MyIntList;
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
How can I call a function, given its name as a string?
|
|
|
|