|
Hello,
Does anyone know why the VC compiler doesn't seem template class method implementation in *.CPP module?
If I place the implementation into *.h file, everything is ok.
Here is the example:
test.h:
=====
template <class t="">
class A
{
public:
A() {};
virtual ~A() {};
int Func();
};
test.cpp:
=======
template <class t="">
int A<t>::Func()
{
asdfghjkl // It must produce compiler error!
ASDASDG
DSFGSDFG
return sizeof(T);
}
main.cpp:
=======
#include "test.h"
int main(int argc, char* argv[])
{
A<double> a;
int n1 = a.Func();
return 0;
}
The Linker can't find implementation of A::func(). If this implementation placed in test.h, everythig works fine!
|
|
|
|
|
There are no compilers out there that support this as of yet. In order to put the code in a .cpp file, the compiler needs to support the export keyword. I don't think you'll find many compilers supporting this for at least a few more years.
In the meantime, simply include your .cpp file in your .h file (I know that's backwards, but you can change it later when the compilers become conforming.
|
|
|
|
|
does anyone has an idea of how to create a playback software which records voice on a microphone and allows playback of the voice in the form a vxd ? Your help will be greatly appreciated.
|
|
|
|
|
Does anyone has a sample code of a playback software which records voice on a microphone an allows playback of the voice in c++? Thanks for replying.
|
|
|
|
|
I just started to learn VC, i got a problem now.
So,would u mind to leave your ICQ Number to me,
then i can contract u directly.Mine is 31161414.
Thank you for your kindly help!
|
|
|
|
|
Don't have ICQ - glad to help if you want to get specific.
|
|
|
|
|
I am trying for months now to create internet sessions
using proxies. The problem is not that creating the sessions
or making http connections fails, but downloading files
from the internet fails.
I have tried using CInternetSession specifying a proxy server
or letting it read the proxy-information used by IE
(INTERNET_OPEN_TYPE_PRECONFIG). Nothing ever worked.
The specific http statuscode returned was 405.
Another problem is, that I don't know how to use proxies
which need authentication. Is there a way to specify username
and password?
Would be great if anyone could help me!
Mike
|
|
|
|
|
Hi,
I am trying to display a circular image as a background with the transparency. The programs work if I use a mask image with the following operations
//draw
BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT);
BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Mask, 0, 0, SRCAND);
BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT);
where m_Image is the DC of the window
and m_Mask is the mask dc.
I try to do the same thing using Region but it don't works. Can anyone helps? Thanks
The code is like
//create th region
HBRUSH hBrush = CreateSolidBrush(RGB(0,0,0));
HBRUSH hOldBrush;
hRegion = CreateEllipticRgn(xPos, yPos, xPos + Width - 1, yPos + Height - 1);
hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
if(FillRgn(hDC, hRegion, hBrush))
DeleteObject(hBrush);
m_bUseRegion = true;
SelectObject(hDC, hOldBrush);
DeleteObject(hBrush);
// create the mask dc
m_Mask = CreateCompatibleDC(hDC);
SelectObject(m_Mask, hRegion);
DeleteObject(hRegion);
//draw
BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT);
BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Mask, 0, 0, SRCAND);
BitBlt(hDC, m_X, m_Y, m_X + m_Width, m_Y + m_Height, m_Image, 0, 0, SRCINVERT);
|
|
|
|
|
How can you select a region into a DC ?
Region can only be selected as clipping region, meta region, or used in PaintRgn directly.
|
|
|
|
|
I am working on an SDI project, and I don't want to have main menu that is placed by the Wizard at all (it's a very simple app, and I'll just use the CToolbarCtrl).
I can't seem to find a way to remove it! If I remove the menu from the resources an exception is thrown; and I can't seem to find any other way to do it...
Can someone please help me?
|
|
|
|
|
The first thing that came to mind is to override CMainFrame::PreCreateWindow() and change the HMENU in the CREATESTRUCT to NULL.
I don't know if this is the "best" or "right" way, it's just the first thing I thought of.
|
|
|
|
|
Try changing CFrameWnd to CMiniFrameWnd. That might or might not be what you want.
|
|
|
|
|
Hi,
I used the following code to show the CFileDialog, but when I exit my application, there was a message in the output window: "The thread 0xFFFAB69D has exited with code -1 (0xFFFFFFFF)."
Is there something wrong?
CFileDialog dlg(TRUE, NULL,"*.bmp;*.jpg;*.gif\0", OFN_FILEMUSTEXIST, "Picture Files (*.bmp;*.jpg;*.gif)|*.bmp; *.jpg; *.gif|All Files(*.*)|*.*||", this);
if(dlg.DoModal() == IDOK)
{
m_strFileName = dlg.m_ofn.lpstrFile;
}
And strange enough: If I change the above "*.bmp" to others text file extension, such as "*.txt", or "*.cpp", no the warning message. I was greatly confused. I am looking forward your kind help.
Thanks;
Feng
|
|
|
|
|
That's not an error message. A thread used by the common dialog just finished running and exited. No worries.
|
|
|
|
|
Why all my control IDs for my FormView don't show up on the ClassWizard uder the Mermber Variables tab?
Is there anything that I can do manually. Any other shortcuts?
Thank you.
|
|
|
|
|
I've seen this with certain controls. Not sure why it happens. What I've done, is manually add them for DDX or subclass the controls using a class derived from their base class...ie CMyListBox from CListBox.
If you want to add them manually, check out the code in the CDialog::DoDataExchange(CDataExchange* pDX) function. That will give you an idea of how to format the new control.
Good luck,
Frank
|
|
|
|
|
If I recall correctly, this was a bug with certain foreign language versions of the IDE (something to do with how your locales are setup). I think this was fixed in one of the service packs though.
|
|
|
|
|
Hi,
I have a MFC application that uses Microsoft Access tables.
The result of my program writes data into a Access database so at the end, I have a Table with the results.
I would like to know: How can I allow the user to save that RESULT TABLE where they SPECIFY the name of the table and the location of where to save it?
If anyone has any ideas, Please let me know.
Thanks in Advance
Steve
|
|
|
|
|
Hi Everyone,
How do I display the data in a Microsoft Access Table with an MFC application?
Can I call up a table from Access for display directly?
If anyone knows, Please let me know.
Thanks in Advance!
Steve
|
|
|
|
|
I'm writting an MMC utility to do some remote admin. I need to be able to connect to a computer by computer name on the local network and stop/start services. I know this can be done through Windows 2000/NT management tools but I need this capability in my MMC snap-in. Does anyone know what library or functions I can use for this task. Just give me a name and I can search on it. Thanks.
|
|
|
|
|
Hi there,
Could somebody help me to figure out how to restore Visual Studion (version 6) settings, of a user in WinNT.
Thus because the user keeps getting an error message: "memory cannot be read" when executing the MSDEV.EXE,
but under the admin and other accounts it's still working fine.
Thanks for any help, or idea
|
|
|
|
|
How to convert a BSTR into LPSTR?
|
|
|
|
|
#include <atlconv.h>
void convert(BSTR bstr)
{
USES_CONVERSION;
LPSTR sz = W2A(bstr);
LPCSTR sz2 = W2CA(bstr);
}
The new strings allocated by the W2A and W2CA macros are on the stack, so they will vanish once the function returns.
|
|
|
|
|
I want that my application will work in english and in my language.
How can I do it?
|
|
|
|
|
This looks like a school project, but it's not.
Having used mutexes and semaphores a zillion times, "finally the time has arrived to write my own implementation for use in an embedded system without OS."
I did some research on the matter and I found Peterson's Algorithm (for 2 processes, threads or whatever) and Lamport's bakery algorithm (for N processes, threads or whatever). There is no need to reinvent "hot water" again, an existing algorithm will do just fine.
For info,
Peterson's Algorithm:
int flag[2] = { FALSE, FALSE } // flag[i] indicates that Pi wants to
// enter its critical section.
int turn = 0; // turn indicates which process has
// priority in entering its critical
// section.
// mutexbegin:
flag[i] = TRUE;
turn = 1 - i;
while (flag[1 - i] && turn == 1 - i)
;
// mutexend:
flag[i] = FALSE;
Now Lamport's Bakery algorithm.
Assumptions:
NPROCS is the number of processes.
max(int *array) returns the maximum value in array.
Each process has a unique ID, so ties on the number chosen are broken by comparing IDs.
Replace i with the appropriate process ID.
// Global initialization:
int choosing[NPROCS] = { FALSE };
int number[NPROCS] = { 0 };
// mutexbegin:
choosing[i] = TRUE;
number[i] = max(number) + 1;
choosing[i] = FALSE;
for (j = 0; j < NPROCS; ++j)
{
while (choosing[j])
;
while (number[j] != 0 && (number[j] < number[i] ||
number[j] == number[i] && j < i) )
;
}
// mutexend:
number[i] = 0;
THE QUESTION:
in the line
number[i] = max(number) + 1;
we see the function 'max'. How do I interprete this?
I thought it meant the maximum of all the numbers in number[], but that does not seam to work.
Also, any suggestions on writing a
bool CPP_Mutex::TryEnter(unsigned int PNumber)
function ?
Any input or pointers greatly appreciated!
NOTE: I know this class produces what is called a "spinning lock", but that's OK.
I tested it with a dual processor machine with the following code:
#define NPROCS 2
#undef Max
#define Max(A,B) ((A)<(B)?(B):(A))
// Implementation of LAMPORTS Bakery Algorithm
class CPP_Mutex
{
public:
CPP_Mutex()
{
memset(m_nChoosing, 0, sizeof(int)*NPROCS);
memset(m_nNumber, 0, sizeof(int)*NPROCS);
}
~CPP_Mutex()
{
}
void Enter(unsigned int PNumber)
{
m_nChoosing[PNumber] = 1;
m_nNumber[PNumber] = MAX(m_nNumber) + 1;
m_nChoosing[PNumber] = 0;
for (unsigned int teller = 0; teller < NPROCS; teller++)
{
while (m_nChoosing[teller])
;
while ( m_nNumber[teller] != 0
&& ( m_nNumber[teller] < m_nNumber[PNumber] ||
m_nNumber[teller] == m_nNumber[PNumber] && teller < PNumber)
)
;
}
}
void Leave(unsigned int PNumber)
{
m_nNumber[PNumber] = 0;
}
protected:
int MAX(int* numbers)
{
int toReturn = 0;
for (unsigned int teller = 0; teller < NPROCS; teller++)
{
toReturn = Max(toReturn, *(numbers+teller));
}
return toReturn;
}
private:
int m_nChoosing[NPROCS];
int m_nNumber[NPROCS];
};
unsigned int value = 0;
unsigned int prevvalue = 0;
bool stop = false;
CPP_Mutex theTestMutex;
void IncreaseValue(unsigned int PNumber)
{
// if (theTestMutex.TryEnter(PNumber))
{
theTestMutex.Enter(PNumber);
prevvalue = value;
value++;
assert(prevvalue == value-1);
// cerr << PNumber << ":" << value << "\t";
theTestMutex.Leave(PNumber);
}
}
DWORD WINAPI ThreadProc( LPVOID lpParameter )
{
while (!stop)
{
IncreaseValue((unsigned int) lpParameter);
}
return 0;
}
int main(int argc, char* argv[])
{
HANDLE hThread1 = NULL;
HANDLE hThread2 = NULL;
DWORD dwThreadID1 = 0;
DWORD dwThreadID2 = 0;
hThread1 = ::CreateThread(NULL, 0, ThreadProc, (void*) 0, 0, &dwThreadID1);
hThread2 = ::CreateThread(NULL, 0, ThreadProc, (void*) 1, 0, &dwThreadID2);
WaitForSingleObject(hThread1, 60000);
stop = true;
WaitForSingleObject(hThread1, INFINITE);
WaitForSingleObject(hThread2, INFINITE);
CloseHandle(hThread1);
CloseHandle(hThread2);
return 0;
}
|
|
|
|
|