|
Strange. I've never seen this behavior. Are you doing dirty tricks with subclassing the dropdown part?
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
I want to replace the last character of a string represented by std::string with comma. How can i do so ??
Example:
std::string mystring("Hellow World");
I want to replace last character of "Hellow World" i.e 'd' by comma "'"
|
|
|
|
|
I wrote this function for this purpose. I hope this helps.
inline void Replace(std::string* pstr, const char old_char, char* pnew_char)
{
if(!pstr->empty())
{
int n = 0;
while((n = pstr->find(old_char)) != -1)
{
*pstr = pstr->erase(n, 1);
*pstr = pstr->insert(n, pnew_char);
}
}
}
Usage:
Replace(&mystring, 'd', ',');
For the last character only you can take:
mystring.erase(mystring.length(), 1);
mystring.append(',');
Greetings ReX
|
|
|
|
|
That's also a way to burn CPU cycles. Another (possibly better) way to do it could be
std::replace(string.begin(), string.end(), 'a', 'b');
to replace all instances of 'a' with 'b'.
|
|
|
|
|
*mystring.rbegin() = '.';
it works
nobody is perfect
|
|
|
|
|
Isn't that to be *(++mystring.rbegin()) = '.'; ?
|
|
|
|
|
nope
rbegin() returns last member of container, as i understand it ))
nobody is perfect
|
|
|
|
|
Then, AFAIK, your understanding is wrong. The doc's I've seen says "The rbegin member function returns a reverse iterator that points just beyond the end of the controlled sequence" and every experience I have with rbegin() says the same.
|
|
|
|
|
I'm trying to enumerate all the different formats for a specific format type, but every time i run the acmFormatEnum function it returns MMSYSERR_INVALPARAM meaning "At least one parameter is invalid.". Anyone know how to use that function? Anyone have some examples? All help is greatly appreciated, here's my code. I start by running the TagEnum function:
ACMFORMATTAGDETAILS acmTagDetails;
void TagEnum()
{
HACMDRIVER hAcm;
acmDriverOpen(&hAcm, id, 0);
acmTagDetails.cbStruct = sizeof(ACMFORMATTAGDETAILS);
acmFormatTagEnum(hAcm, &acmTagDetails, acmTagCallback, NULL, 0);
acmDriverClose(hAcm, 0);
}
BOOL WINAPI acmTagCallback(HACMDRIVERID hadid, LPACMFORMATTAGDETAILS paftd, DWORD dwInstance,DWORD fdwSupport)
{
ACMFORMATDETAILS acmFormat;
WAVEFORMATEX waveFormat = { 0 };
HACMDRIVER hAcm;
memset(&acmFormat, 0, sizeof(acmFormat));
acmFormat.cbStruct = sizeof(acmFormat);
acmFormat.cbwfx = sizeof(waveFormat);
acmFormat.pwfx = &waveFormat;
acmFormat.dwFormatTag = acmTagDetails.dwFormatTag;
waveFormat.wFormatTag = acmTagDetails.dwFormatTag;
acmDriverOpen(&hAcm, hadid, 0);
acmFormatEnum(hAcm, &acmFormat, formatCallback, NULL, ACM_FORMATENUMF_WFORMATTAG);
acmDriverClose(hAcm, 0);
return TRUE;
}
BOOL WINAPI formatCallback(HACMDRIVERID hadid, LPACMFORMATDETAILS pafd, DWORD dwInstance, DWORD fdwSupport)
{
ACMDRIVERDETAILS details;
details.cbStruct = sizeof(details);
acmDriverDetails(hadid, &details, NULL);
SendMessage(GetDlgItem(ghWnd, IDC_FORMATS), LB_INSERTSTRING, 0, (LPARAM)details.szLongName);
return TRUE;
}
id is a HACMDRIVERID holding a valid driver id of a driver. Anyone have a clue what could be wrong or have some examples?
All help is apprecaited.
-Rune Svendsen
|
|
|
|
|
Doesn't the MSDN sample ACMapp display how to do this???
|
|
|
|
|
Hi,
I have an ActiveX control that I want to view from a HTML view, I could embed it directly in my application but there are some features which are only activated when its a plugin for IE.
The problem is that the Control overrided the OnDblClick and OnChar messages from the HTMLView and handles them iteself.
Is there any way arround this?
If there isn't my only other solution is to make sure the View does not get focus. Is there any way to ENSURE that a view never gets the focus?
Thanks
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Yes, one solution is to override event handlers associated to the HTML document :
- ondblclick for OnDblClik windows command
- onkeyup for OnChar windows command
The HTML document is obtained with code like this :
CComQIPtr<IHTMLDocument2> pHtmlDoc( GetHtmlDocument() );
|
|
|
|
|
Hi,
I want to create a dialogue box that has a hole in it... Essentially, it is a window that covers another window created by another application. But I want a square hole in my dialogue that shows part of the window beneath it (kind of like those envelopes that you get with a square cutout in the front showing your address that is printed on the letter it contains).
Does anybody know how I can do this? I am using the Windows API.
Many thanks for any suggestions,
Keith
|
|
|
|
|
HRGN hOrgRgn;
::GetWindowRgn(hWnd, hOrgRgn);
HRGN hRectRgn = ::CreateRectRgn(0, 0, 100, 100);
HRGN hResultRgn;
::CombineRgn(hResultRgn, hOrgRgn, hRectRgn, RGN_XOR);
::SetWindowRgn(hWnd, hResultRgn);
something like this should help
nobody is perfect
|
|
|
|
|
Hi, many thanks for your reply.
I tried the rgn method, and finally got this code working:
hOrgRgn=CreateRectRgn(0,0,0,0);
GetWindowRgn(hWnd, hOrgRgn);
hRectRgn = CreateRectRgn(50, 10, 200, 200);
hResultRgn=CreateRectRgn(0,0,0,0);
CombineRgn(hResultRgn, hOrgRgn, hRectRgn, RGN_XOR);//RGN_DIFF); //rgn_diff makes no difference
SetWindowRgn(hWnd, hResultRgn,TRUE);
But unfortunately, this does exactly the *opposite* of what I want. This cuts out a square from the middle of the window, but it only shows the cut out square and not the rest of the window; I want to show the window with a square hole in the middle. I've tried swapping around "hOrgRgn" and "hRectRgn" in CombineRgn(), but it makes no difference.
Does anybody have any suggestions?
Again, many thanks,
Keith
|
|
|
|
|
// get screen coordinates
RECT OrgRect;
GetWindowRect(hWnd, &OrgRect);
POINT ptLT, ptRB;
ptLT.x = OrgRect.left;
ptLT.y = OrgRect.top;
ptRB.x = OrgRect.right;
ptRB.y = OrgRect.bottom;
// convert to client
ScreenToClient(hWnd, &ptLT);
ScreenToClient(hWnd, &ptRB);
// convert from client area to entire window area
ptRB.x -= ptLT.x;
ptRB.y -= ptLT.y;
ptLT.x -= ptLT.x;
ptLT.y -= ptLT.y;
// create new region for window
HRGN hNewRgn = CreateRectRgn(ptLT.x, ptLT.y, ptRB.x, ptRB.y);
// "hole" region
HRGN hRectRgn = CreateRectRgn(ptLT.x+50, ptLT.y+50, ptRB.x-50, ptRB.y-50);
// combine them
HRGN hResultRgn = CreateRectRgn(0, 0, 0, 0);
CombineRgn(hResultRgn, hNewRgn, hRectRgn, RGN_DIFF);
SetWindowRgn(hWnd, hResultRgn, TRUE);
this one works for sure
can send you a demo project
nobody is perfect
|
|
|
|
|
After downloading a very large program, I noticed ALL its files (both '.h' and '.cpp') were "Read Only". Is there a way I can uncheck ALL the files at once (from their "Read Only" status), rather than uncheck them one by one?
Secondly, I noticed even though the program compiled and linked with 0 errors, 0 warnings, and it works fine, NONE of its files could be seen in ClassView!! NONE!!
All its resources files could be seen, and all its FileView files could be seen, but NOTHING available in ClassView.
Is there some way I can get ClassView to show the class layout of the files too?
Thanks.
William
|
|
|
|
|
This is probably because the files were in Visual Source Safe or something like that...
WREY wrote:
Is there a way I can uncheck ALL the files at once (from their "Read Only" status), rather than uncheck them one by one?
Yup, in explorer select all the files (Ctrl+A) and get the properties (Alt+Enter), then uncheck the Read only box
WREY wrote:
Is there some way I can get ClassView to show the class layout of the files too?
Yup, removing the read only attribute should do this.
Hope this helps...
Dylan Kenneally
London, UK
|
|
|
|
|
Hi
I'm tying to make a program with lot's of line drawing. I've use
CClientDC dc(this);
CView::OnPrepareDC(&dc);
in my functions to draw those lines (I put metafile in the OnDraw()function). Somehow I was running out of resources when I execute the program. Is it because I've declared too many CDC object? Can somebody tell me what might be wrong here? Should I put all those line drawing in the OnDraw() function instead?
Newbies
|
|
|
|
|
Zayax wrote:
Should I put all those line drawing in the OnDraw() function instead?
Newbies
Yes. Do you use CreateSolidBrush or CreatePen or something alike? If you do, check up that you release all GDI objects (pen, brush, etc.) after painting.
|
|
|
|
|
What if i jush use a simple constructor like
CPen BluePen( PS_SOLID, 0, COLOR_BLUE) what should i do?
Newbies
|
|
|
|
|
select it into a DC, grab the pen returned when you do so, and make sure you put the old pen back into the DC before deleting it.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Hi I started five processes from a console program. Now i want to monitor these processes and show how many of them are still running every second. So how do i know the state of these processes? Here are my code:
[code]
while (WaitForMultipleObjects(5, proHandle, TRUE, 1000) == WAIT_TIMEOUT);
{
for(i = 0; i <5; i++)
{
if(proHandle[i] ==0)
runningProcess--;
}
printf(" %d ", runningProcess);
}
[/code]
|
|
|
|
|
Have a look at GetExitCodeProcess .
|
|
|
|
|
But it doesn't seem to work!! Does the following piece of code look alright ? Thanks
while (WaitForMultipleObjects(5, proHandle, TRUE, 1000) == WAIT_TIMEOUT);
{
for(i = 0; i <5; i++)
{
if(!GetExitCodeProcess(proHandle[i], &status[i]))
cerr << "GetExitCodeProccess Fail" << endl;
if(status[i] != STILL_ACTIVE )
runningProcess--;
}
printf(" %d ", runningProcess);
}
|
|
|
|
|