|
How are you guys using WTL in brand new VC7 projects? The compilation fails because of _Module being undefined. I tried using all crap like
#define _Module (*_pAtlModule)
It didnot solve all teh problems though. I had to create a fake module class to do that. Is there a simpler way anyone is using? If not will this be an article material?
Somewhere in the world there is a machine language programmer waiting for that damned assembly language fad to pass. - Stan Shanon
|
|
|
|
|
Stick the following in your stdafx.h file:
#include <atlapp.h>
extern CAppModule _Module;
|
|
|
|
|
Hi,
SafeArrayGetUBound function sets the upper bound to -1. but it returns S_OK. the safeArrayAccessData function also returns S_OK.
this happens only under win 98. everything is ok under win NT 4 and win XP. I use MSComm control and m_comm is a pointer to that. the MSComm object always exists in my dialog based application and is always in binary input mode. It sends 6 byte binary data successfully, but it cannot get the coming 6 bytes.
i need to get each byte of the coming data. i cannot make a big change in the way of receiving the data (i will continue with MSComm) because, I am all finished except for win98.
does someone know a way to fix this problem?
thanks in advance
--------
Here is some of my code:
.
.
.
COleVariant vVar;
dlg_p->m_comm.SetOutput(var_rb); // data sent
Sleep(50); // wait
vVar = dlg_p->m_comm.GetInput(); // received
//vVar.Attach(dlg_p->m_comm.GetInput()); // this doesn't change anything
Sleep(50); // wait
long lLen;
unsigned short data = 0;
HRESULT hr = SafeArrayGetUBound(vVar.parray,1,&lLen);
if(hr == S_OK)
{
lLen++;
UCHAR *pAccess;
hr = SafeArrayAccessData(vVar.parray, (void**)&pAccess);
if(hr == S_OK)
{
// under win98 lLen is 0 here.
if(lLen==6)
// stuff with pAccess[]
SafeArrayUnaccessData(vVar.parray);
}
}
.
.
.
----------
|
|
|
|
|
Hi All
i have a edit control, which i use to display text, within this text there
is usually a web address.
is it possible for me to make this a hyperlink ? or display a hyperlink
within a text box ??
thanks
si
|
|
|
|
|
Have you considered a rich-edit control?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
you'd better custom-draw your edit control
|
|
|
|
|
As David posted earlier, you could do this with a RichEdit control.. Here's how I have done it in the past.. the example is using a RichEdit control in a dialog box..
unsigned mask = m_cRichEdit.GetEventMask();
m_cRichEdit.SetEventMask(mask | ENM_LINK);
m_cRichEdit.SendMessage(EM_AUTOURLDETECT,TRUE,0);
if(message == WM_NOTIFY)
{
if(((LPNMHDR)lParam)->code == EN_LINK)
{
ENLINK* p = (ENLINK *)lParam;
if (p->msg == WM_LBUTTONDOWN)
{
ENLINK* p = (ENLINK *)lParam;
m_cRichEdit.SendMessage(EM_EXSETSEL, 0, (LPARAM)&(p->chrg));
m_cRichEdit.SetSel(p->chrg);
CString strLink = m_cRichEdit.GetSelText();
ShellExecute(NULL, "open", strLink, NULL, NULL, SW_SHOWNORMAL);
}
}
}
Don't forget to do a AfxInitRichEdit(); inside the Init of the APP..
Hope this helps,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I have a C program that has some static arrays of Number/String pairs (error number to descriptive text mapping). I thought that this would be great to have in a C++ collection class (std::map, or CMap in windows). Now apart from the weird template syntax, this would work nicely.
However, to initialise the collection class, I have to run an initialiser function that loads in the collection entries, either as hard-coded values in the source code, or by reading a file.
In the case of hard-coded values in the source code, the application ends up with two copies of the data in memory. Not as efficient as old C static arrays.
In the case of file reading, there is the overhead of the load procedure.
IS there any way, or proposed C++ standard, to initialise a collection/classes at compile-time - so you could pre-fill the data elements as easily as you can currently define array elements?
|
|
|
|
|
One solution is a DLL. Initialize the containers in the class contructor.
Kuphryn
|
|
|
|
|
I've been handed some code in Matlab to
convert to c++. Although I am familiar with Matlab,
I have come across:
while 1 % forever do...
% carry out a calculation
end % end forever do
with no obvious termination condition. My question
is, how will this loop ever terminate as I need
the c++ function version of it to eventually return
a value? I suspect I should be looking for a
return or break statement
but can't seem to locate one inside the while loop.
I am thinking this loop is not coded correctly, but
have been assured that it works...
I'm not exactly a Matlab Guru, so maybe I am missing
something?
John Theal
Physicist/Mathematical Programmer
Digital Immersion Software Corporation
Got CAD?
http://www.presenter3d.com[^]
http://www.merlin3d.com[^]
|
|
|
|
|
I don't know Metlab at all but just looking at your post, could it be possible that it will break out of the loop if the condition "l" becomes false?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
|
look for a break or a return within the loop
J.
----------------------------
|
|
|
|
|
Welcome!!! I looking for description of UPX compressed exe files. How can I - programmatically - read PE header of oryginal file - before compression. In most cases that is not protected, so in theory it's possible - but how ?
Sorry 4 my polish
Mila
|
|
|
|
|
Hi
I have a program which runs in command line version, I need to collect the
output which commandline version is displaying with "cout<<" and have to store it in a file, I could do it with the ios::sync_with_stdio()
If I need to dispay the same output on some control say Edit control in runtime, is there any way??
Thanks in advance
Warm Regards,
R.Krishnan
|
|
|
|
|
Hello, after finally getting the Winsock Layered Service Provider sample from MSDN to work i'm now facing another problem. I modified the WSPRecvFrom function to be able to intercept UDP packets that are being read by an application. I then write the data to a logfile to see what is being read. But when i do this i end up with files that have vast planes of zero buffers in it, and inbetween this large pieces of zeros theres the data (so yea it works). My question is though, how can i get rid of these zeros, they are only in the way, is there a way to filter them out or am i missing something? Also, i thought when u intercept the data like this u only get like the exact data that is being read, and this is weird because i did the same for the WSPRecv function before and then opened my browser and i got like some binary data first, hows that possible? since the HTTP protocol is text based... I really don't get it. Here's how i modified the function so far:
inline INT
DPROVIDER::WSPRecvFrom(
IN SOCKET s,
IN LPWSABUF lpBuffers,
IN DWORD dwBufferCount,
IN LPDWORD lpNumberOfBytesRecvd,
IN OUT LPDWORD lpFlags,
OUT struct sockaddr FAR * lpFrom,
IN LPINT lpFromlen,
IN LPWSAOVERLAPPED lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
IN LPWSATHREADID lpThreadId,
OUT INT FAR *lpErrno
)
{
INT ReturnValue;
if (PREAPINOTIFY(( DTCODE_WSPRecvFrom,
&ReturnValue,
m_lib_name,
&s,
&lpBuffers,
&dwBufferCount,
&lpNumberOfBytesRecvd,
&lpFlags,
&lpFrom,
&lpFromlen,
&lpOverlapped,
&lpCompletionRoutine,
&lpThreadId,
&lpErrno)) ) {
return(ReturnValue);
}
FILE* logf;
logf = fopen("D:\\lsplog.txt","a");
for(int i=0;i<(int)dwBufferCount;i++)
{
if(lpBuffers[i].len > 0)
{
fwrite("\r\n",strlen("\r\n"),1,logf);
fwrite(lpBuffers[i].buf,lpBuffers[i].len,1,logf);
}
}
fclose(logf);
ReturnValue = m_proctable->lpWSPRecvFrom(
s,
lpBuffers,
dwBufferCount,
lpNumberOfBytesRecvd,
lpFlags,
lpFrom,
lpFromlen,
lpOverlapped,
lpCompletionRoutine,
lpThreadId,
lpErrno);
POSTAPINOTIFY(( DTCODE_WSPRecvFrom,
&ReturnValue,
m_lib_name,
&s,
&lpBuffers,
&dwBufferCount,
&lpNumberOfBytesRecvd,
&lpFlags,
&lpFrom,
&lpFromlen,
&lpOverlapped,
&lpCompletionRoutine,
&lpThreadId,
&lpErrno));
return(ReturnValue);
}
Kuniva
--------------------------------------------
|
|
|
|
|
Does anyone know of a C/C++ utility/library which can convert a ddif document to a tif?
|
|
|
|
|
Hi all,
We're trying to make a different language version of our product. We've implemented dynamic .DLL resource loading.
The problem is editing the resource file, which has to be done by people outside the company (since none of us speak Japanese). VS .NET 2003 (and below) don't seem to allow us to enter Katakana characters, instead, it replaces them with ????. Even on Japanese systems. Even running Japanese Visual Studio.
We tried converting the resource file to UNICODE, and then we can have whatever characters we want in the file, but the UNICODE file can't be edited in Visual Studio - which won't do for translation purposes.
Does anyone have any experience with this sort of thing? Any third-party resource editor reccommendataions? Any experience trying to edit a resource file in a different locale?
Thanks,
Eco
|
|
|
|
|
... we needed the Japanese version of .NET to enter Japanese multibyte resources. Thanks, Microsoft.
Eco
|
|
|
|
|
Hi ,
im Trying to Make an Right-to-Left MFC Application , But I got a probelm which it cant be viewd correctly
I Tried the Right-to-Left Reading Order option under the extend Styles , but it failed and I always got it view like this ---> E?IE?
Any idea What Can I do to make it View correct ?
Thanks in advanced
|
|
|
|
|
E?IE? makes no sense. What are you trying to display?
The WS_EX_RTLREADING style is only supported for shell languages in Hebrew, Arabic, or another languages that support reading-order alignment.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
yeah , But How can I manage to make my application write and read such letters ?
|
|
|
|
|
I'd imagine you'd have to install a version of Windows that supported Hebrew, Arabic, or another languages that support reading-order alignment.
http://support.microsoft.com/default.aspx?scid=kb;en-us;311019
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
i am writing a very simple program which allocates some memory for an array...
it is running under vc++ 6.0 or 7.1, on a athlon xp , 512 mb of ram, win xp pro. the big problem is that when i try to allocate something like 200 mb of ram memory (out of ~380 mb available), the program takes forever just to allocate the memory, and after that the computer begins to run extremely slow, even after i deallocate the memory. and if i run the program again and try to allocate memory again, windows will only allow me to allocate virtual memory, althought there's enough ram memory free that could be allocated... that's how i have written the program:
...
int main()
{
long size=25000;
long *array;
cout << "Will now allocate memory for the array..." << endl;
array=new long [size*sizeof(long)];
cout << "Memory allocated sucessfully..." << endl;
cout << "Will now deallocate the memory..." << endl;
delete[] array;
system("pause");
return 0;
}
i used a program (memtest) to test if this could be caused by defective ram memory, but i dont think thats the cause of that...
thanx
|
|
|
|
|
Anonymous wrote:
the program takes forever just to allocate the memory
What did you expect?
"It is better to remain silent and be thought a fool than to open one's mouth and remove all doubt." - Abraham Lincoln
|
|
|
|
|