|
best posts as always. Good work, keep it up
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Hi,
Can some one provide me sample example for storing/retriving object of class from storage medium(i.e file)?
Mike.
|
|
|
|
|
|
I have a CString CString str= 104032;
how can i get substrings like 4032 or 32 or 04032 in vc++
thanks & regards
|
|
|
|
|
You can use Mid()of CString.
- ns ami -
|
|
|
|
|
l_d wrote: how can i get substrings like 4032 or 32 or 04032 in vc++
By reading here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
You can use Find().It will return the postion of the first character then use Mid()to extract that
Thanks & Regards
VIJITH VIJAYAN
|
|
|
|
|
Hi,
I have a pushbutton "Cancel" in my DialogBox that for some reason the Code doesn't get activated when I click on it
Actually the appearence seems give a hint of what the problem might be
When the Dialog comes up the button seems to have a perferation around it as if it is in a depressed state
I coded the DEFPUSHBUTTON as I have others but it does respond the same way below is the code for the Dialog
IDD_DIALOG6 DIALOGEX 0, 0, 316, 180
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Storage View"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
--> DEFPUSHBUTTON "Cancel",IDCANCEL1,205,159,50,14 <-- BUTTON IN QUESTION
CONTROL "",IDC_RICHEDIT21,"RichEdit20A",ES_MULTILINE | ES_WANTRETURN,80,28,180,105
LTEXT "Storage",IDC_STATIC,30,28,30,8
END
|
|
|
|
|
Did you override OnCancel() in your dialog class.
«_Superman_»
|
|
|
|
|
I am using plain old Win32 SDK
|
|
|
|
|
I just want you to check if you have mapped IDCANCEL and not destroying the dialog.
«_Superman_»
|
|
|
|
|
This the entire Dialog Code right below WM_INITDIALOG is the IDCANCEL1 case
I think the problem is the the Cancel button appears to be disabled meaning as if it has aleady been depressed (perferation around the button) Which is why in the INITDIALOG I do a BM_SETSTATE meesage
thankx again
case WM_INITDIALOG:
{
RichWindow = GetDlgItem(hwndDlg,IDC_RICHEDIT21);
SetFocus(RichWindow);
SendDlgItemMessage(hwndDlg, IDCANCEL1, BM_SETSTATE,0,0);
strncpy(&stor_start[0],&command[2],8); // copy command buffer
stor_start[8] = 0x00; // null mark
start_stor = atoi((const char *) &stor_start[0]); // convert to decimal
strncpy(&stor_end[0],&command[11],8); // copy over buffer
stor_end[8] = 0x00; // mark ens
end_stor = atoi((const char *) &stor_end[0]);
SendDlgItemMessage(hwndDlg, IDC_RICHEDIT21, EM_SETWORDBREAKPROC, 0, (LPSTR) EditWordBreakProc);
strcpy(&stor_char[0],&stor_start); // start at the begining
strncpy(&stor_buffer[0],&stor_start[0],8);
for (stor_count = start_stor; stor_count < end_stor; stor_count +=16)
{
memset( &cf, 0, sizeof cf );
cf.cbSize = sizeof cf;
cf.dwMask = CFM_COLOR;
cf.crTextColor = RGB(255,0,0);
cr.cpMin = 1;
cr.cpMax = 7;
SendDlgItemMessage(hwndDlg, IDC_RICHEDIT21, EM_EXSETSEL,0,&cr); // Set the Seelction
SendDlgItemMessage( hwndDlg, IDC_RICHEDIT21, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf);
strncpy(&stor_buffer[10],&buffer[buff_count],4);
buff_count+=4;
strncpy(&stor_buffer[15],&buffer[buff_count],4);
buff_count+=4;
strncpy(&stor_buffer[21],&buffer[buff_count],4);
buff_count+=4;
strncpy(&stor_buffer[26],&buffer[buff_count],4);
buff_count+=4;
stor_buffer[32]= '/r';
SendDlgItemMessage(hwndDlg, IDC_RICHEDIT21, WM_SETTEXT,0, (LPARAM) &stor_buffer[0]);
mysettext.flags = ST_DEFAULT;
mysettext.codepage = CP_ACP;
SendMessage(Stor_edit,EM_SETTEXTEX,&mysettext,(LPSTR) &stor_buffer[0]);
}
return TRUE;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
switch (LOWORD (wParam))
{
case IDCANCEL1:
DestroyWindow(hwndDlg);
hwndDlg = NULL;
break;
}
}
default:
return FALSE;
}
}
|
|
|
|
|
ForNow wrote: case WM_COMMAND:
switch (LOWORD(wParam))
{
switch (LOWORD (wParam))
{
case IDCANCEL1:
DestroyWindow(hwndDlg);
hwndDlg = NULL;
break;
}
}
If this is not a cut/paste error, remove one of these switch statements so that you have:
case WM_COMMAND:
switch (LOWORD (wParam))
{
case IDCANCEL1:
DestroyWindow(hwndDlg);
hwndDlg = NULL;
break;
}
Judy
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|
I am going to look at my code at home as I when I got the a Answer to my post
I was on my way to work (rushed) but I beleive I only have one switch
thankz again
|
|
|
|
|
In addition to Judy's reply...
WM_COMMAND is used for more than just button clicks - it's also used for
other notifications from a control to its parent.
You may want something more like this:
switch (LOWORD (wParam))
{
case IDCANCEL1:
if (BN_CLICKED == HIWORD(wParam))
{
DestroyWindow(hwndDlg);
hwndDlg = NULL;
return 0;
}
break;
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thankx I'll try it when I get home BTW do you think the ES_WANTRETURN could be giving me problems with DEFPUSHBUTTON as with that style the Dialog takes control of the <enter> key which otherwise would cuase the DEFPUSHBUTTON to be activated
thankx again
|
|
|
|
|
ForNow wrote: do you think the ES_WANTRETURN could be giving me problems with DEFPUSHBUTTON
Possibly...
"ES_WANTRETURN
Specifies that a carriage return be inserted when the user presses
the ENTER key while entering text into a multiline edit control in a
dialog box. If you do not specify this style, pressing the ENTER key
has the same effect as pressing the dialog box's default push button.
This style has no effect on a single-line edit control. "
If the edit control has focus, hitting the enter key won't be
translated into a default push button press.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you Judy and Mark
Code is working
|
|
|
|
|
hi all
i am writing a thread per client server, well its not really a server, but it destributes jobs and calculations to other connected PCs.
i have been having this error
Free Heap block 00DB3D28 modified at 00DB3D78 after it was freed
Windows has triggered a breakpoint
now i traced the corruption of the heap by using _heapchk() and i found that the heap is being corrupted after a call to select() with fd_set containing one socket to check it for readability, the call to _heapchk() befor the select() returns _HEAPOK and after the select() it returns _HEAPBADNODE.
the call to select() is inside the client specific thread, the first client that connects has no problem at all, when a second client connects the select() works fine untill there are nothing to read from the socket, call select() and returns zero then the heap corrupts, how to solve such a problem where the code is not under my control???? i am using VC++ 2005 and win xp.
another thing, the thread proc is part of an object, that is creating a thread by calling a static function passing pointer to an object and inside the static function call a member function of object, dose that effect the heap in any way harmful??? i used to do it all the time with no problems.
here is the thread code:
thread(void* pParam)
{
int bytesSent,bytesToBeSent;
int bytesRecv = SOCKET_ERROR;
char sendbuf[4096] = "";
char recvbuf[4096] = "";
char tempbuf[4096] = "";
short* aa = (short*) &sendbuf[0];
*aa = PGA_CMD_SENDSTATE;
bytesToBeSent = 2;
bytesSent = send( socket, sendbuf, bytesToBeSent, 0 );
aa=NULL;
NotCritical = true;
int cmd,i,j,s,ret = 0;
TIMEVAL t;
t.tv_sec=0;
t.tv_usec=5000;
fd_set fd;
while( 1 )
{
FD_ZERO(&fd);
FD_SET(socket,&fd);
int hs2 = _heapchk();
ret = select(0, &fd, NULL, NULL, &t);
hs2 = _heapchk();
if ( ret > 0 )
{
s=0;
bytesRecv = recv( socket, recvbuf, 4096, 0);
if(bytesRecv == SOCKET_ERROR)
goto ERR;
cmd = *(short*)recvbuf;
j=2;
switch(cmd)
{
}
}
else
{
if( ret < 0)
goto ERR;
}
}
ERR:
closesocket(socket);
state |= CI_STATE_ERROR;
isBad = true;
return 0;
}
any ideas??????
if i comment out the line
i can connect as many clients i want with no problem, but the thread will not read any thing from the socket since ret is always zero.
Ali Usam AlCherchefchi
modified on Monday, January 26, 2009 8:06 PM
|
|
|
|
|
|
hi.
ive implemented a simple bho object with an IOleCommandTarget interface.
i have my Exec method and its called upon a click event of a toolbar button ive added to IE.
the method looks like that :
STDMETHODIMP CHelloWorldBHO::Exec(const GUID *pguidCmdGroup,
DWORD nCmdID, DWORD nCmdExecOpt,
VARIANTARG *pvaIn, VARIANTARG *pvaOut)
{
HRESULT hr = S_OK;
HWND hwnd;
if(m_spWebBrowser!=NULL)
HRESULT hr1 = m_spWebBrowser->get_HWND((LONG_PTR*)&hwnd);
else
{
MessageBox(NULL, _T("No Web browser pointer"), _T("Oops"), 0);
}
return hr;
}
it always displays the "No Web browser pointer" message.
it seems my spWebBrowser variable is null even though ive implemented SetSite method.
i know that SetSite is fired when IE loads because im handeling an event of IE and it works fine.
my button is registerd in :
HKLM {
NoRemove SOFTWARE
{
NoRemove Microsoft
{
NoRemove 'Internet Explorer'
{
NoRemove Extensions
{
ForceRemove '{5D578929-E74E-46A2-A810-4F33D011DC51}'
= s 'PageCop' {
val 'Default Visible' = s 'yes'
val 'ButtonText' = s 'Inspect page'
val 'CLSID' = s '{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}'
val 'ClsidExtension' =
s '{A414425C-2E84-4CA3-B7F0-BCA49A9F89D6}'
val 'Icon' = s 'C:\icons\WinXP\search4doc.ico'
val 'HotIcon' = s 'C:\ icons\WinXP\search4doc.ico'
}
}
}
}
}
}
my bho is registerd in :
HKLM {
NoRemove SOFTWARE {
NoRemove Microsoft {
NoRemove Windows {
NoRemove CurrentVersion {
NoRemove Explorer {
NoRemove 'Browser Helper Objects' {
ForceRemove '{A414425C-2E84-4CA3-B7F0-BCA49A9F89D6}' = s 'HelloWorldBHO' {
val 'NoExplorer' = d '1'
}
}
}
}
}
}
}
}
anyone knows thats the problem?
|
|
|
|
|
Make sure you are assigning m_spWebBrowser in the SetSite function by doing a QueryInterface on the passed in IUnknown pointer.
«_Superman_»
|
|
|
|
|
im sure that m_spWebBrowser is assigned because im handeling an event of the browser and their im using m_spWebBrowser .
|
|
|
|
|
Hi All,
I had ported an application from VC++ 6.0 to VC++ 9.0.
When i copy just the exe to another machine, it runs only if there is an VC++ 2008 redistributable.
Is VC++ redistributable required, if i am making a MSI package and distributing my application?
Is .Net 3.5 required on the destination machines, if i am making a MSI package and distributing my application?
When there is no .Net 3.5 on the destination machine and no VC++ 2008 redist, my exe when run says
"This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix the problem"
When i create a MSI package with installer like wise,
is the .Net 3.5 need to be installed on the destination machines? or even VC++ Redistributable also need to be installed on the destination machines?
Thanks,
|
|
|
|
|
Guess what - the answer's the same as when you asked this question before[^].
You need the VC++2008 redist for your program to run. You need to install that either within your MSI or separately - doesn't really matter which route you take, except obviously it's more convenient if you bunle it all up in the MSI.
|
|
|
|
|