|
Hello
I'll assume that CVPP is Visual C++, right? Well, like it in what exactly? What functionality do you need in your pictureBox that is not present in the MFC Picture Control?
Regards
|
|
|
|
|
Ty, maybe it's good too but I can't find a documentation on MSDN about it.
It just not there.
Can someone please help me to find the documentation?
SnaidiS(Semion)
|
|
|
|
|
Ok I was arranged thank you!
SnaidiS(Semion)
|
|
|
|
|
After 3 weeks of 18x7 trying to retrieve text from the item 0 of a virtual list view control, came to realize that must have the pointer to the item data in the DRAWITEMSTRUCT of a WM_DRAWITEM message but, the properties of the struct are 0000(no state!) for the item State and 00000000 for the item Data! Can anyone tell me what the heck is going on here please?
The application could be trying very hard to make this data inaccessible but, how is it doing that? The Window proc. Of the control also appears as subclassed! Could that be the cause?
All in all, there are 2 messages only produced amongst all of the messages sent & received by the control and it’s parent that can lead me to the text, the WM_DRAWITEM & the LVMINSERTITEM, well the former I already explained the problem with and the latter also has the LV_ITEM attributes as follows:
Mask: 0000, State:0000, state Mask:0000, cch Text Max: 84190885 which none of them again help to show the text pointer!
There are no other messages produced that could be of any use other than the ones for the headers that are crystal clear and have all the data showing.
How can I hack the data out of this LV control???? BTW, the hack is quite legal and legitimate.
Thanks for your help
p.s.
the virtual list control has the data painted and drawn onto it so there are not any of the usual setitem/getitem/settext etc. messages available. I have also studied very hard all possibilities of subclassing and hooking but my question remains, how can intercepting the say LVM_DRAWITEM above help? Unless, by subclassing it after receiving the message above and redelivering it back to the control, could I then throw a getitem message at it and hopefully it might then respond correctly??? Or something of similar nature?
|
|
|
|
|
A list control in virtual mode doesn't keep that information. The point of virtual mode is for the application to keep all that data, and only provide it to the list when the list needs to redraw. So if you have a virtual list control, then you must already have that text.
|
|
|
|
|
Thanks Mike for reponding. I am also getting lots of good help from another Mike on the thread below in another forum.
You say I must already have the text(that's what I think too or else how would the control display it?)?! I guess you mean within the memory space of te control? if so then how would I get to it, I do not see any messages that would lead me to them.
thanks again
Cy
http://www.codeguru.com/forum/showthread.php?t=399176&page=1&pp=15
|
|
|
|
|
having problem
background
system XP SP2
borland BCC55
editor scite
when i make simple programs such as hello world etc every thing works fine but then when i try to use
#include
it tends to throw out errors about not being able to include MFC .h files
i tried getting hold of them but its just getting worse now
list off error message
Error E2209 c:\Borland\Bcc55\include\afxv_w32.h 125: Unable to open include file 'zmouse.h'
Warning W8094 c:\Borland\Bcc55\include\afx.h 4760: Incorrect use of #pragma comment( <type> [,"string"] )
Error E2187 c:\Borland\Bcc55\include\afx.h 6585: Unexpected end of file in conditional started on line 4671
Warning W8059 c:\Borland\Bcc55\include\afx.h 6585: Structure packing size has changed
Error E2139 c:\Borland\Bcc55\include\shellapi.h 49: Declaration missing ;
Error E2209 c:\Borland\Bcc55\include\afxwin.h 29: Unable to open include file 'afxres.h'
Error E2209 c:\Borland\Bcc55\include\afxwin.h 33: Unable to open include file 'afxcoll.h'
Error E2080 c:\Borland\Bcc55\include\afxwin.h 350: '__stdcall CDumpContext::operator <<(CArchive &,tagSIZE)' must be declared with one parameter
Error E2080 c:\Borland\Bcc55\include\afxwin.h 351: '__stdcall CDumpContext::operator <<(CArchive &,tagPOINT)' must be declared with one parameter
Error E2080 c:\Borland\Bcc55\include\afxwin.h 352: '__stdcall CDumpContext::operator <<(CArchive &,const tagRECT &)' must be declared with one parameter
Error E2080 c:\Borland\Bcc55\include\afxwin.h 353: '__stdcall CDumpContext::operator >>(CArchive &,tagSIZE &)' must be declared with one parameter
Error E2080 c:\Borland\Bcc55\include\afxwin.h 354: '__stdcall CDumpContext::operator >>(CArchive &,tagPOINT &)' must be declared with one parameter
Error E2080 c:\Borland\Bcc55\include\afxwin.h 355: '__stdcall CDumpContext::operator >>(CArchive &,tagRECT &)' must be declared with one parameter
Error E2209 c:\Borland\Bcc55\include\afxwin.h 1221: Unable to open include file 'afxmsg_.h'
Error E2209 c:\Borland\Bcc55\include\afxwin.h 1250: Unable to open include file 'afxdd_.h'
Error E2293 c:\Borland\Bcc55\include\afxwin.h 2327: ) expected
Error E2293 c:\Borland\Bcc55\include\afxwin.h 2516: ) expected
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 2668: 'CDumpContext::CDialog::Create(const char *,CDumpContext::CWnd *)' hides virtual function 'CDumpContext::CWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int,CDumpContext::CCreateContext *)'
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 2702: 'CDumpContext::CStatic::Create(const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int)' hides virtual function 'CDumpContext::CWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int,CDumpContext::CCreateContext *)'
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 2739: 'CDumpContext::CButton::Create(const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int)' hides virtual function 'CDumpContext::CWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int,CDumpContext::CCreateContext *)'
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 2824: 'CDumpContext::CListBox::Create(unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int)' hides virtual function 'CDumpContext::CWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int,CDumpContext::CCreateContext *)'
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 2972: 'CDumpContext::CComboBox::Create(unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int)' hides virtual function 'CDumpContext::CWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int,CDumpContext::CCreateContext *)'
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 3039: 'CDumpContext::CEdit::Create(unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int)' hides virtual function 'CDumpContext::CWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int,CDumpContext::CCreateContext *)'
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 3066: 'CDumpContext::CScrollBar::Create(unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int)' hides virtual function 'CDumpContext::CWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int,CDumpContext::CCreateContext *)'
Error E2303 c:\Borland\Bcc55\include\afxwin.h 3198: Type name expected
Error E2139 c:\Borland\Bcc55\include\afxwin.h 3198: Declaration missing ;
Error E2293 c:\Borland\Bcc55\include\afxwin.h 3299: ) expected
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 3321: 'CDumpContext::CFrameWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,const char *,unsigned long,CDumpContext::CCreateContext *)' hides virtual function 'CDumpContext::CWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int,CDumpContext::CCreateContext *)'
Error E2451 c:\Borland\Bcc55\include\afxwin.h 3112: Undefined symbol 'AFX_IDW_PANE_FIRST'
Error E2451 c:\Borland\Bcc55\include\afxwin.h 3149: Undefined symbol 'CBRS_ALIGN_TOP'
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 3460: 'CDumpContext::CMDIChildWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CMDIFrameWnd *,CDumpContext::CCreateContext *)' hides virtual function 'CDumpContext::CWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int,CDumpContext::CCreateContext *)'
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 3460: 'CDumpContext::CMDIChildWnd::OnUpdateFrameMenu(int,CDumpContext::CWnd *,HMENU__ *)' hides virtual function 'CDumpContext::CFrameWnd::OnUpdateFrameMenu(HMENU__ *)'
Warning W8022 c:\Borland\Bcc55\include\afxwin.h 3528: 'CDumpContext::CMiniFrameWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int)' hides virtual function 'CDumpContext::CWnd::Create(const char *,const char *,unsigned long,const tagRECT &,CDumpContext::CWnd *,unsigned int,CDumpContext::CCreateContext *)'
Error E2303 c:\Borland\Bcc55\include\afxwin.h 4009: Type name expected
Error E2139 c:\Borland\Bcc55\include\afxwin.h 4009: Declaration missing ;
Error E2238 c:\Borland\Bcc55\include\afxwin.h 4013: Multiple declaration for 'CDumpContext::CDocManager::CPtrList'
Error E2344 c:\Borland\Bcc55\include\afxwin.h 4009: Earlier declaration of 'CDumpContext::CDocManager::CPtrList'
Error E2139 c:\Borland\Bcc55\include\afxwin.h 4013: Declaration missing ;
Error E2228 c:\Borland\Bcc55\include\afxwin.h 4013: Too many error or warning messages
the code im tring to compile
// PortScan.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "PortScan.h"
#include "MainFrm.h"
#include "PortScanDoc.h"
#include "PortScanView.h"
#include "Splash.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPortScanApp
BEGIN_MESSAGE_MAP(CPortScanApp, CWinApp)
//{{AFX_MSG_MAP(CPortScanApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPortScanApp construction
CPortScanApp::CPortScanApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CPortScanApp object
CPortScanApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CPortScanApp initialization
BOOL CPortScanApp::InitInstance()
{
// CG: The following block was added by the Splash Screen component.
\
{
\
CCommandLineInfo cmdInfo;
\
ParseCommandLine(cmdInfo);
\
\
CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
\
}
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("IP Hole Finder, (C)By Arash Afifi Sabet"));
LoadStdProfileSettings(0); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CPortScanDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CPortScanView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
m_pMainWnd->SetWindowText("IP Hole Finder, Port Scanning");
m_pMainWnd->CenterWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CPortScanApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CPortScanApp message handlers
BOOL CPortScanApp::PreTranslateMessage(MSG* pMsg)
{
// CG: The following lines were added by the Splash Screen component.
if (CSplashWnd::PreTranslateAppMessage(pMsg))
return TRUE;
return CWinApp::PreTranslateMessage(pMsg);
}
if any one can recomend what i should do or a better way to go about learning C++ i do know java perl basic and some others so writing it hasnt been to hard but it seems i cant get to grips with compiling it
|
|
|
|
|
Please don't post the complete code, it is unnecessary. Also use the code and pre tags to format your code (it is impossible to read).
For your question, I seriously doubt that the borland compiler supports the MFC (never worked with it).
|
|
|
|
|
What I want to do is probably impossible, but regardless, I would still like your thought and comments.
Lets say we have a c style string. We have a pointer to the begining and the end is found by increasing the pointer until we reach a null char. strings 101. But now lets say we have a 'fragmented' string (ie there are two halves to the same string, each half having a pointer. We know both pointers we also know the exact length of each part.
First. Is it possible to return this string from a function, without allocating, copying and merging?
Second. Is it possible to write a string to fragmented memory like this? Again without chopping.
Idealy what I want is to line the pointers up, taking the block size into account, and return a single pointer.
|
|
|
|
|
No because a "string" in C isn't a built-in type, it's a convention that says an array of char s, marked with 0 at the end, is called a "string". All CRT string functions expect to operate on arrays such as that.
If you split up the array, then by definition it's no longer a "string" so you'll need to write your own code to handle that new kind of string.
|
|
|
|
|
It's looks like I am going to have to do this the long way. The reason I ask is that I have strings of up to some 10mb in length, yet these are stored in 4k chunks. I cannot be sure if the chunks would be sequencial. It seems a shame to have to allocate 10mb of memory just to return a single string which is already in memory.
I think the only way I could increase performance is to check if the memory is sequencial, if so return the first pointer, if not reallocate the whole thing.
|
|
|
|
|
My program has many thread, every pair of threads has its own memory block.
When one thread want to change value of variable, is it possible to just lock its couple instead of locking every other threads that will never touch that block of memory?
|
|
|
|
|
I'm not sure I understand very clearly. Between two threads there is 1 block of shared memory? How are you locking the memory?
I would use a mutex and create a unique name for every block of shared memory. That way there would only ever be two threads trying to lock the same mutex.
|
|
|
|
|
When I use mutex lock, it will stop every thread from running instead of stop only thread that trying to access that variable, right?
if yes, could you please give me a short example about mutex locking specify thread
|
|
|
|
|
No. When you create a mutex you can give it a unique name. So you need a different name for each pair of threads. Because only 2 threads will share the same mutex name, they will only ever be able to lock each other out. So, for example, you have 10 threads with 5 blocks of memory, you should create 5 mutex names.
|
|
|
|
|
A customer of mine has sent me a user.dmp file generated when a debug version of an application of mine crashes. The application was compiled with VS2005. Now, I thought I could open and then run .dmp files in Visual Studio, but when I run this file I get the following error:
Debugging older format crashdumps is not supported
Anyone know how I can extract some useful information from this .dmp file? The call stack would be useful and it would at least give me some idea where the problem occurs!
Thanks in advance.
|
|
|
|
|
Downloaded windbg and this allows me to open the file...
|
|
|
|
|
lmao, I was just scratching my brains trying to remember the name of that program so I could tell you to try it.
|
|
|
|
|
I would like to loop through a vector<string> type and remove the contents of strSearch from
all the lines within Sentences.
CSentences.h
...
std::vector <std::string> Sentences; //list of sentences.
...
The following function returns the number of occurrences of strSearch within sentence.
CSentences.cpp
unsigned int CSentenceList::searchInSentence(const string sentence, char* strSearch)
{
char buffer[MAX_SENTENCE_LENGTH + 1] = {0};
const char* l_strSentence = sentence.c_str();
memcpy(buffer, l_strSentence, MAX_SENTENCE_LENGTH);
char* strToken = 0;
unsigned long iWordCount = 0;
strToken = strstr(buffer, strSearch);
while (strToken !=NULL)
{
if (strlen(strToken) > 0)
{ // For each line within Sentences
// remove strSearch
iCount++;
strToken += strlen(strSearch);
}
strToken = strstr(strToken, strSearch);
}
return iCount;
}
Jon
|
|
|
|
|
The following function removes all occurances of strSearch in sentence:
void StringRemove(std::string& sentence, const char * const strSearch)
{
size_t len = strlen(strSearch);
std::string::size_type i = sentence.find(strSearch);
while(i != std::string::npos)
{
sentence.erase(i, len);
i = sentence.find(strSearch, i);
}
}
If, as the title of your post suggests you actually want to replace a substring use the following:
void StringReplace(std::string& sentence,
const char * const strSearch,
const char* const strNew)
{
size_t len = strlen(strSearch);
size_t newLen = strlen(strNew);
std::string::size_type i = sentence.find(strSearch);
while(i != std::string::npos)
{
sentence.replace(i, len, strNew, newLen);
i = sentence.find(strSearch, i + newLen);
}
}
To replace all occurances in the vector use:
std::vector<std::string>::iterator i;
for(i = sentences.begin(); i != sentences.end();++i)
StringReplace(*i, "foo", "bar");
BTW a more succinct version of your count occurances in string function is
unsigned int StringCount(const std::string& sentence,
const char* const strSearch)
{
unsigned int count = 0;
size_t len = strlen(strSearch);
std::string::size_type i = sentence.find(strSearch);
while(i != std::string::npos)
{
i = sentence.find(strSearch, i + len);
++count;
}
return count;
}
Graham
My signature is not black, just a very, very dark blue
|
|
|
|
|
This function REMOVES sub-string of strText starting at iStart and resuming at iStart + iNoOfChars:
string CSentenceList::subString(char* strText, int iStart, int iNoOfChars)
{
int iLength = strlen(strText);
char l_Substring[MAX_SENTENCE_LENGTH];
// copy character by character till iStart
for (int iFirstCount = 0; iFirstCount < iStart; iFirstCount++)
{l_Substring[iFirstCount] = strText[iFirstCount];}
// copy from iContinue till the end of the text
int iContinue = iStart + iNoOfChars;
for (int iSecondCount = iContinue; iSecondCount < iLength; iSecondCount++, iFirstCount++)
{l_Substring[iFirstCount] = strText[iSecondCount];}
return (string) l_Substring;
}
However, the string returned is terminated by a series of unreadable characters. For example, substring ("joe123joe",3,3) should return "joejoe", but it returns:
joejoe╠╠╠╠╠╠╠╠... // up to the value of MAX_SENTENCE_LENGTH (1000)
I have tried using dynamic arrays of chars but I had trouble converting them to std::string type.
Jon
|
|
|
|
|
Add a NULL terminator to the end of the string. Or better still, call memset() for l_Substring and zero the memory.
memset(l_Substring,0,MAX_SENTENCE_LENGTH);
|
|
|
|
|
I think the above line zero's the memory for l_Substring. I would like to remove what has not already been 'filled' within the function.
How do I add a NULL terminator btw?
Jon
|
|
|
|
|
jon_80 wrote: I think the above line zero's the memory for l_Substring. I would like to remove what has not already been 'filled' within the function.
When you memset with '0', you are filling the array with NULL terminators, so after you add your characters one by one there will be a NULL at the end.
jon_80 wrote: How do I add a NULL terminator btw?
After you have added the last character, increase the pointer and make it = '0' instead of adding a character.
|
|
|
|
|
string CSentenceList::removeSubstring(char* strText, int iStart, int iNoOfChars)
The NULL is not started at the end of the string though...
{
int iLength = strlen(strText);
char l_Substring[MAX_SENTENCE_LENGTH];
// copy character by character till iStart
for (int iFirstCount = 0; iFirstCount < iStart; iFirstCount++)
{l_Substring[iFirstCount] = strText[iFirstCount];}
// copy from iContinue till the end of the text
int iContinue = iStart + iNoOfChars;
for (int iSecondCount = iContinue; iSecondCount < iLength; iSecondCount++, iFirstCount++)
{l_Substring[iFirstCount] = strText[iSecondCount];}
memset(l_Substring,0,MAX_SENTENCE_LENGTH); //resets l_Substring to ""
return (string) l_Substring;
}
Jon
|
|
|
|
|