|
Hi All, I am carrying out a simple localization project. I have a dialog based application and the target language is Hebrew. I would like to know how to Right-Align the texts which apppear in the MessageBoxes. I am able to Right-justify text messages, by using the option MB_RTLREADING. There is an option called MB_RIGHT. However this does not work. Please advise
|
|
|
|
|
hello, i know i can get a function pointer into a function by declaring the function as:
setfunction(double (*funcPointer)(double)); // for example
but i'm having difficulty returning funcPointer from an accessor. for eg do i declare the accessor as:
double (*)(double) getfunction(); // should return the function pointer
unfortunately this does not work, and i cannot see where i am going wrong.
any help would be great!
|
|
|
|
|
typedef is your friend:
typedef double (* pfnGetDouble) (double);
double GetDouble(double d)
{
return d;
}
pfnGetDouble GetDoubleFunc()
{
return (pfnGetDouble) GetDouble;
}
int main()
{
pfnGetDouble pfGD = GetDoubleFunc();
printf("%f\r\n", pfGD(42.0));
}
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Is it possible to develop a simple SNTP server on a WINDOWS machine ?
Tanks a lot !
|
|
|
|
|
The simple answer is yes.
See SNTP[^]
Gives details of the simple network time protocol.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Hi,
i'm beginner programmer.
I want to know....
How to read data from comport..
I want to receive from send comport.
Is use "ReadFile" for read data..
and then how to reteive string.
If comport send some text for example-"Hello word",
how to get this is??
i alreadly have serial class for serial communication.
this is following ..
int CSerial::ReadDataWaiting( void )
{
if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );
DWORD dwErrorFlags;
COMSTAT ComStat;
ClearCommError( m_hIDComDev, &dwErrorFlags, &ComStat );
return( (int) ComStat.cbInQue );
}
int CSerial::ReadData( void *buffer, int limit )
{
if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );
BOOL bReadStatus;
DWORD dwBytesRead, dwErrorFlags;
COMSTAT ComStat;
ClearCommError( m_hIDComDev, &dwErrorFlags, &ComStat );
if( !ComStat.cbInQue ) return( 0 );
dwBytesRead = (DWORD) ComStat.cbInQue;
if( limit < (int) dwBytesRead ) dwBytesRead = (DWORD) limit;
bReadStatus = ReadFile( m_hIDComDev, buffer, dwBytesRead, &dwBytesRead, &m_OverlappedRead );
if( !bReadStatus ){
if( GetLastError() == ERROR_IO_PENDING ){
WaitForSingleObject( m_OverlappedRead.hEvent, 2000 );
return( (int) dwBytesRead );
}
return( 0 );
}
return( (int) dwBytesRead );
}
open,close,send data function i can use.
but i cannot use this read function.
how to use this.
yet,i don't know.
pls explain me..
how to work this..
|
|
|
|
|
How about doing it simple to start with?, all that overlapped functionality and error handling is great when you know what's going on, but for starters you should keep things simple.
(The code below is from memory and not debugged)
#define MAX_BUFFER 1024
int main()
{
char portName[] = "COM1";
char buffer[MAX_BUFFER];
HANDLE hFile;
hFile = CreateFile(
portName,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (INVALID_HANDLE_VALUE != hFile)
{
if (ReadSerial(hFile, buffer, MAX_BUFFER))
{
printf("Received: '%s'\r\n", buffer);
}
}
}
BOOL ReadSerial(HANDLE hFile, char * buffer, DWORD bufferSize)
{
BOOL retval;
DWORD dw;
buffer[0] = '\0';
retval = FALSE;
if (ReadFile(hFile, buffer, bufferSize - 1, &dw, NULL))
{
retval = TRUE;
buffer[dw] = '\0';
}
return retval;
}
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Hi friends,
I need to construct and traverse a multiway tree. Does anybody having any doc/alogrithm/URL regarding this?
VikramS
|
|
|
|
|
Not sure which type you want, but read about these...
http://www.cs.princeton.edu/~rs/strings/
|
|
|
|
|
vikrams wrote:
I need to construct and traverse a multiway tree.
What kind (e.g., binary, tertiary, splay, red/black)?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hie,
I am having n numbers of nodes , and this case is true for all child nodes.I dont know what they call for such type of tree.
|
|
|
|
|
Google for N-ary or M-ary tries.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
hi, everyone, I am wondering that how can Macromedia FlashPlayer draw more
than 300thousands lines, polygons and texts so fast? At first I thought that
it uses cached map that are generated when the swf file be opened. but I
check the disk space and find out that it only occupies 4MB disk space for
cache. If it draws all visible shapes in real time, the question comes , how
can it do that so quickly? does anybody has any ideas on this question??
|
|
|
|
|
Can any one help me how to add tooltips for combo boxes in vc++
thanx
|
|
|
|
|
LOOK HERE ,YOU'LL FIND THE ANSWER!
http://www.codeproject.com/miscctrl/pptooltip/cpptooltip_src.zip
http://www.codeproject.com/miscctrl/pptooltip/cpptooltip_demo.zip
|
|
|
|
|
i'm doing a install for my program,but don't know it need some other files.how to find all the files (such as .dll) that the program depending on?Thanks !
|
|
|
|
|
Are you trying to create your own installer? There are available installer creaters that can do the job for you!
If you want to find out depending dlls, you can check this using depends tool
ARSALAN MALIK
|
|
|
|
|
thanks Arsalan ,
i am too looking out for Depends tool.
thanks Again
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
This issue is really a serious Issue ..
I have made simple Dialog based application which contains a web Browser Control .. Every thing is working fine, navigation , downloading pages is just kool .. now I want to fill the Form the fields with the help of this code
void CMyDlg::OnDocumentComplete(LPDISPATCH pDisp, VARIANT FAR* URL)
{
// TODO: Add your control notification handler code here
// Fill the Input field and Submit the Form
LPDISPATCH lpDispatch =NULL;
HRESULT hr;
lpDispatch = m_WebBrowser.GetDocument();
hr = lpDispatch->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&m_pHTMLDocument2);
lpDispatch->Release();
lpDispatch = NULL;
int Index[5];
Name.Add(_T("INPARAM1"));
Value.Add(_T("4321"));
Name.Add(_T("INPARAM2"));
Value.Add(_T("4321"));
Name.Add(_T("INPARAM3"));
Value.Add(_T("4321"));
Index[0] = 2 ;
Index[1] = 3 ;
Index[2] = 4 ;
AddData(Index,&Name,&Value);
}
} Every thing is fine , but there is performance issue as I starts filling the Form Fields with the help of this Interfce it takes almost 85% of memory usage .. and it is not good any Solutions to this .. I would be very grate ful to you guys .. Thanx
Why Only this opertaion Takes so much of the CPU time ... ?
- Nabil
|
|
|
|
|
Hi,
Think you are having a memory problem. Release the memory allocated 4 variants by using VariantClear
This may help you
Sujan
|
|
|
|
|
I am writing a "C" application (not C++, not MFC) running on Win98SE which captures audio from line-in into a wrap-around ring of 40mSec buffers. When the user stops capture, the last audio which was captured is combined with PAL video frames (25Hz) from a frame grabber into an AVI file.
The capture works fine with a small numbers of buffers (125 buffers for 5 seconds), but when I try 1 minute (1500 buffers), the program gets to about buffer 300 during the waveInPrepareHeader() stage, which then returns an error value of 7 (MMSYSERR_NOMEM, explained in the mmsystem.h file as "memory allocation error".) About this time, Win98 becomes unstable! Once, Windows gave the error "System is dangerously low on resources . . .".
I ran resource meter, and when MMSYSERR_NOMEM is reported by my program, resource meter reports 92% system resources, 92% user resources, 95% GDI resources. System monitor reports 550 Meg of free physical memory.
Does anyone know what waveInPrepareHeader() is actually doing, what the system is running out of, and how I can fix it?
I can work around the problem by grabbing the audio in half-second chunks instead, but that complicates the code.
The test program runs fine on Windows XP, so I could also try to migrate to XP, but I want to understand what is happening!
Any ideas?
Here is a console application which demonstrates the problem (on my PC, it fails at header 301 or so)
<br />
#include "stdafx.h"<br />
#include <windows.h><br />
#include <vfw.h><br />
#include <mmsystem.h><br />
<br />
#define DEF_BlocksPerSecond 25<br />
#define DEF_NumAudioBlocks 1500<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
unsigned int uiNumWaveInDevices;<br />
unsigned int uiCounter;<br />
unsigned int uiReturn;<br />
char szTempString[100];<br />
WAVEINCAPS WaveInCaps;<br />
BOOL bSoundModeValid;<br />
HWAVEIN hWaveInDevice;<br />
WAVEFORMATEX WaveFormat;<br />
unsigned int uiAudioBufferNumBytes;<br />
<br />
WAVEHDR WaveHeaders[DEF_NumAudioBlocks];<br />
<br />
uiAudioBufferNumBytes = 11025 * 2 / DEF_BlocksPerSecond;<br />
<br />
uiNumWaveInDevices = waveInGetNumDevs();<br />
<br />
for (uiCounter=0; uiCounter < uiNumWaveInDevices; uiCounter++)<br />
{<br />
waveInGetDevCaps(uiCounter, &WaveInCaps, sizeof(WaveInCaps));<br />
bSoundModeValid = WaveInCaps.dwFormats & WAVE_FORMAT_1M16;<br />
if (bSoundModeValid)<br />
break;
}<br />
<br />
if (!bSoundModeValid)<br />
return(1);
<br />
WaveFormat.wFormatTag = WAVE_FORMAT_PCM;<br />
WaveFormat.nChannels = 1;
WaveFormat.nSamplesPerSec = 11025;
WaveFormat.nBlockAlign = 2;
WaveFormat.wBitsPerSample = 16;
WaveFormat.nAvgBytesPerSec = 11025 * 2;
WaveFormat.cbSize = 0;
<br />
hWaveInDevice = NULL;<br />
<br />
uiReturn = waveInOpen(&hWaveInDevice,uiCounter-1,&WaveFormat,0,0,CALLBACK_NULL);<br />
if (uiReturn != MMSYSERR_NOERROR)<br />
{<br />
MessageBox(0, "Error opening wave in device", "WaveInOpen Error",<br />
MB_OK);<br />
return (2);
}<br />
<br />
for(uiCounter = 0; uiCounter<DEF_NumAudioBlocks; uiCounter++)<br />
{<br />
WaveHeaders[uiCounter].lpData = <br />
GlobalLock(GlobalAlloc(GMEM_FIXED, uiAudioBufferNumBytes));<br />
if (WaveHeaders[uiCounter].lpData == NULL)<br />
{<br />
MessageBox(0, "Error allocating wave data", "Wave Data Error",<br />
MB_OK);<br />
return (3);
}<br />
<br />
WaveHeaders[uiCounter].dwBufferLength = uiAudioBufferNumBytes;<br />
WaveHeaders[uiCounter].dwBytesRecorded = 0;<br />
WaveHeaders[uiCounter].dwUser = 0;<br />
WaveHeaders[uiCounter].dwFlags = 0;<br />
WaveHeaders[uiCounter].dwLoops = 0;<br />
uiReturn = waveInPrepareHeader(hWaveInDevice, &(WaveHeaders[uiCounter]),<br />
sizeof(WAVEHDR));<br />
if (uiReturn != MMSYSERR_NOERROR )<br />
{<br />
sprintf(szTempString, "Error %d preparing header %d.",<br />
uiReturn, uiCounter);<br />
MessageBox(0, szTempString, "Wave Data Error", MB_OK);<br />
return(4);<br />
}<br />
}<br />
<br />
MessageBox(0, "Allocated and prepared all buffers - cleaning up!",<br />
"All successful!", MB_OK);<br />
<br />
return 0;<br />
}
|
|
|
|
|
You should only have one or two buffers prepared at any given time.
Then when you respond to the callbacks, you give the MM system the next buffer, calling waveInUnprepareHeader on the buffer it just finished using. So by double or triple buffering the data, you are allowing the multimedia to fill one while you are preparing another, and you unprepare the one it just finished filling. I think you are overflowing some internal buffer that can only handle up to 300 prepared headers at a time.
something like this:
prepare 3 headers and feed the MM system the first buffer
when it calls back and says it has filled it, give it second, and COPY the data from your first buffer to your own local storage
when it has filled second buffer, give it your thrid, etc.
repeat cycle until your waveform sampling is complete
I found this all works best from a thread that can handle the events from the mm system instead of doing it frojw ith the same thread, then I can copy the data out of a buffer and 'reprepare' that buffer while the MM system is busy sampling, instead of being blocked waiting for a sample buffer to fill.
|
|
|
|
|
(At home and can't remember my password so not logged in!)
Thanks - your suggestion sounds good but it means I have to handle the buffers in real time, and I'm lazy! I guess it's either do it your way or change to Windows XP, which I was considering anyway.
By the way, I tried my application on 2 other Windows 98SE PCs, and their behaviour was not the same as the original PC.
My original PC gave me a message when preparing buffer number 301, then gave the error code 7 - NOMEM - dialog box. The other two would prepare 1000 buffers, but when I tried 10000 buffers, they terminated with no message.
I guess it's just poor Win98 audio drivers!
NormanS
|
|
|
|
|
The event driven, ring buffering technique is the 'preferred' method. It worked for me back in 1993 on Windows 95 and Windows NT 4.0 machines (slow 66 MHz 80486 systems) with no problem. Yours should be fine if you adopt the same technique, given the speed of today's processors.
|
|
|
|
|
Hi Oliv - thanks for your comments.
The application I posted was just one I put together to investigate the problem, not my "real" project (which is about 9000 lines of code.) Since I found the problem in audio header preparation in my real project, that is where I stopped in the test application. It's a console application because I did not want anything to distract me from the real problem with the audio.
The actual project is an SDK-level Windows program, mainly because (1) I based my project on a sample project which was written in SDK-level C, and (2) I learned programming long ago, and I haven't bothered to learn this "modern" C++ / MFC stuff! (Also, I program in other environments using ANSI C, so I don't want to pick up C++ habits.)
The GlobalAlloc is not the problem. To test this, I changed the program slightly, so it allocates memory in one loop, and once all the data blocks are allocated, it starts to prepare the headers. The error occurs at about the same header (number 301 on my main development PC.) I have allocated 10000 blocks with no problems.
Unfortunately, I do need to capture 1 minute of audio. My main application is a video capture and processing program, which displays processed video in real-time. The user can stop at any stage, and step back and forward through the LAST minute of video, which I keep in memory in a ring of video buffers. He might have been playing the video for an hour, but I just keep the last minute of video frames. Once he stops, he can also save the 1 minute of video as an AVI file. That bit works, but I thought it would be a good idea to add audio to the AVI file, which is when I hit the problems.
I think the solution will probably be to use a smaller number of audio buffers (5 or 10), and transfer these into my own array of buffers whenever they are full.
|
|
|
|
|