|
You can use MoveWindow in wm_size
whitesky
|
|
|
|
|
i have access detail for ODLserver current API program as follow : user,acount,password,and the port no.
Now i want to make connection with server.
I have created a vc6 dialog based application which include activex control in that...now i am able to add active x in my dialog box...
My confusion is how to write a code which make connection with ODL server
|
|
|
|
|
How can we insert a new item to another program's ListCtrl control?
I do this:
LVITEM lvi, *_lvi;
char item[512], *_item;
unsigned long pid;
HANDLE process;
GetWindowThreadProcessId(myHwnd1, &pid);
process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid);
_lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE);
_item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE);
lvi.cchTextMax=512;
lvi.iSubItem=1;
lvi.pszText=_item;
// WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL);
// ::SendMessage(myHwnd1, LVM_GETITEMTEXT, (WPARAM)0, (LPARAM)_lvi);
// ReadProcessMemory(process, _item, item, 512, NULL);
lvi.iItem = 1;
lvi.iSubItem = 0;
lvi.pszText=_item;
WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL);
i = (int)::SendMessage(myHwnd1, LVM_INSERTITEM, (WPARAM)0, (LPARAM)_lvi);
But there is problem when execute above, memory violate....
Who can help me??please!!!
Who can help me??please!!!
|
|
|
|
|
Hi All,
I created one MFC extension dll and loaded the exporated function in another sample
MFC SDI application on click of the toolbar events.This application is almost looks
simmilar to paintbrush where the exported functions are having the implementaion of
painting methods.The MFC sample EXE is just to call the extention DLL and call each
exported fucntion(in .DEF file of MFC Extension DLL) to test whether the actions are having or not but for one function i am getting runtime error while excuting the MFC
sample EXE i.e. "Debug Assertion Failed".
Program path of the sample MFC SDI exe......
File : wingdi.cpp
Line : 1054
I am giving following code snippets....
HDC hdc = NULL;
UINT uIntRect = 0;//RECTANGLE;
HWND hwnd = NULL;
BOOL uReturnVal= FALSE;
LPFNDLL_drawShape lpfndll_drawRectangle;
HMODULE hModule = LoadLibrary("D:\\FancyViewer\\Notebook_13July2006\\Notebook\\Debug\\Notebook.dll");
if(hModule)
{
lpfndll_drawRectangle = (LPFNDLL_drawShape)GetProcAddress(hModule,"drawShape");
if (!lpfndll_drawRectangle)
{
AfxMessageBox("GetProcAddress() method is failed");
FreeLibrary(hModule);
return;
}
else
{
CRect rect;
GetClientRect(rect);
CPaintDC dc1(this);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc1);
hwnd = (HWND)dc1.GetWindow();
hdc = dc1.Detach();
uIntRect = RECTANGLE;
// call the function of drawShape method for rectangle of Notebook.dll
uReturnVal = lpfndll_drawRectangle(hdc,uIntRect,hwnd);
ASSERT(uReturnVal == TRUE);
char buffer[65];
MessageBox(_itoa(GetLastError(),buffer,10),NULL,MB_OK);
return;
}
}
else
{
AfxMessageBox("Load library failed");
return;
}
GetLastError();
|
|
|
|
|
|
Is it possible to use an inherited class (CIosDialog : CDialog) as the base class in ClassWizard (instead of seeing CDialog as the base class, CIosDialog as the base class)?
Thanks.
John P.
|
|
|
|
|
jparken wrote: Is it possible to use an inherited class (CIosDialog : CDialog) as the base class in ClassWizard (instead of seeing CDialog as the base class, CIosDialog as the base class)?
Add the class as a generic class and then type in the base class name in the New class dialog.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Hello,
I am curious to know if there exist a built-in Regular expressions algorhythm in C++ that can search patterns in a file and display them on the screen?
Thanks
|
|
|
|
|
Harold_Wishes wrote: display them on the screen?
I don't believe any Regular Expression Engine will know anything about displaying results on a screen.
Harold_Wishes wrote: can search patterns in a file
It is also unlikely that a Regular Expression Engine will know about searching files.
Harold_Wishes wrote: built-in Regular expressions algorhythm
Regular Expressions are not part of the ISO C++ standard... yet. There is a Regular Expression Library in Boost (boost.org)
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
I am trying to create a dynamic string array m_pSentences[iLineCount], where iLineCOunt is the number of lines in a text file.
What should the synthax be?
Error:
(35): error C2440: '=' : cannot convert from 'char (*)[1000]' to 'char *'
Code:
char strSentence [MAX_SENTENCES_PER_FILE + 1] [MAX_CHARS_PER_SENTENCE + 1] = {""};
char strFileToRead[MAX_FILEPATH_LENGTH + 1] = {"c:\\temp\\testfile.txt"};
int iLineCount = 0;
// read the file and update temporary array
fstream file_op(strFileToRead, ios::in);
while(!file_op.eof())
{
file_op.getline(strSentence[iLineCount], MAX_CHARS_PER_SENTENCE);
iLineCount++;
}
file_op.close();
// create an array of sentences
char *m_pSentences;
m_pSentences = new char[iLineCount + 1] [MAX_CHARS_PER_SENTENCE];
for (int iIndex = 0; iIndex <= iLineCount; iIndex++)
{
strcpy(strSentence[iIndex], m_pSentences);
//m_pSentences[iIndex] = *strSentence[iIndex];
}
for (int iIndex = 0; iIndex <= iLineCount; iIndex++)
{
cout << m_pSentences[iIndex] << endl;
}
delete [] m_pSentences;
}
Jon
|
|
|
|
|
char *m_pSentences[MAX_SENTENCES_PER_FILE];
but, you'd be much better off using CString or std::string and some kind of container class:
vector< std::string > sentences;
sentences.push_back("this is sentence 1.");
sentences.push_back("this is sentence 2.");
or
CStringArray sentences;
sentences.Add("this is sentence 1.");
sentences.Add("this is sentence 2.");
messing around with multi-dim arrays is more trouble than it's worth, in most cases.
Do the chickens have large talons?
-- modified at 22:42 Monday 17th July, 2006
|
|
|
|
|
Chris Losinger wrote: messing around with multi-dim arrays is more trouble than it's worth, in most cases.
What is it worth?
|
|
|
|
|
it's worth knowing how multi-dim arrays work. not everything can (or should) be put into a vector - strings definitely should.
Do the chickens have large talons?
|
|
|
|
|
Chris Losinger wrote: it's worth knowing how multi-dim arrays work
Trixy answer... I like it!
|
|
|
|
|
I’m trying to create a function that creates an array of strings when reading from a text file.
This object seems to require afxcoll.h to be included and I've included them in my console application, however a couple of errors crop up. I also tried to include it within an MFC application, since this is an MFC class, but they won't compile as well.
Sentences error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in libcpd.lib(newop.obj)
Sentences error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCD.lib(dbgdel.obj)
Sentences error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCD.lib(delete2.obj)
Sentences error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)
Sentences error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)
Code (to test):
CStringArray strSentences;
strSentences.Add("mary");
strSentences.Add("george");
Any idea why?
Jon
|
|
|
|
|
looks like you're mixing different versions of the C run-time libraries - one or more files in your app are compiled with the single-threaded CRT, but others are built with a different CRT. "new" and "delete" are defined in both, and the linker doesn't know which one to use. so, make all your files/modules/libraries use the same CRT version.
Do the chickens have large talons?
|
|
|
|
|
How would I check the CRT version?
Also, why is the following error being displayed?
Error
.cpp(17): fatal error C1010: unexpected end of file while looking for precompiled header directive
Code example:
#include ".\SentenceAr.h"
#include <string>
#include <iostream>
CSentenceArray::CSentenceArray(string strFileToRead, bool bCreateArray)
{}
CSentenceArray::~CSentenceArray()
{};
Jon
|
|
|
|
|
jon_80 wrote: How would I check the CRT version?
two different places:
project Properties (or Settings) General / Microsoft Foundation Classes
or, C/C+ / Category:Code Generation / Use Run-time Library.
that's VC6. VS03/05 are in similar places.
jon_80 wrote: Also, why is the following error being displayed?
you need to add #include "stdafx.h" to the top of the file.
Do the chickens have large talons?
|
|
|
|
|
Does the project have to be an MFC project or can I include the MFC classes by including files?
I am using a console project to develop the classes because the code is simpler to test that way.
I have tried all the options within VS2003 for Run-time library but the code wouldn't compile in any case.
Also, I could not find stdafx.h, is it because it's not an MFC project?
Jon
|
|
|
|
|
jon_80 wrote: Does the project have to be an MFC project or can I include the MFC classes by including files?
it's far easier to do it from a project that was created to work with MFC than it is to add MFC after the fact. i'm not sure of all the steps, but you'll need to #include some stuff, set some #defines for the compiler, link the appropriate MFC libs, etc..
if you already have a non-MFC project, you might be better off with using std::string and std::vector:
#include < string>
#include < vector>
using namespace std;
...
vector < string > sentences;
sentences.push_back("this is a sentence");
sentences.push_back("this is another sentence");
...
string s = sentences[0];
etc.
Do the chickens have large talons?
|
|
|
|
|
|
Hi fellows
I`m trying to create a treeview in my app but I don`t have any sucess.
I`ve read the Microsoft article [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/treeview.asp[/url]
and I`ve tried to do something like that. The problem is that whem I create a node in a function that I created it returns NULL. I think that my code is right, so what`s going on??
Thanks for the support.
Below is my code?
I created my treeview like this:
<br />
treeViewHwnd = CreateWindowEx(WS_EX_LEFT, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 150, 600, hwnd, NULL, hCurrentInstance, NULL);<br />
treeViewHwnd is a global HWND.
In this part I want to put a node in the treeview
<br />
case WM_CHAR:<br />
{<br />
switch(wParam)<br />
{<br />
case 'a':<br />
{<br />
InitCommonControls();<br />
treeViewHwnd = GetDlgItem(hwnd, IDC_TREE1);<br />
OpenedWindows(GetForegroundWindow());<br />
for(int i = 0 ; i < sNameHwnds.size() ; i++)<br />
{ <br />
InsertNodeInTV(hwnd, sNameHwnds[i], 1);<br />
MessageBox(NULL, sNameHwnds[i].c_str(), "", MB_OK);<br />
break;<br />
}<br />
break;<br />
}<br />
.....<br />
And here I create the node:
<br />
#define IDC_TREE1 10<br />
HTREEITEM InsertNodeInTV(HWND tvHwnd, string sNodeName, int iLevel)<br />
{<br />
static HTREEITEM ParentItem, BeforeItem, RootItem;<br />
ParentItem = (HTREEITEM)TVI_FIRST;<br />
BeforeItem = RootItem = NULL;<br />
TVINSERTSTRUCT treeViewInsert;<br />
treeViewInsert.item.mask = TVIF_TEXT;<br />
treeViewInsert.item.pszText = (char*)sNodeName.c_str();<br />
treeViewInsert.item.cchTextMax = sizeof(treeViewInsert.item.pszText)/treeViewInsert.item.pszText[0];<br />
treeViewInsert.hInsertAfter = TVI_ROOT;<br />
treeViewInsert.hParent = NULL;<br />
ParentItem = (HTREEITEM)SendDlgItemMessage(tvHwnd, IDC_TREE1, TVM_INSERTITEM, 0, (LPARAM)&treeViewInsert);<br />
if(ParentItem == NULL)MessageBox(NULL, "aaa", "", MB_OK);<br />
return ParentItem;<br />
}<br />
|
|
|
|
|
Besides the fact that "int iLevel" is not used the rest of the code runs correctly when I have good values like tvHwnd, IDC_TREE1, etc. Therefore I suspect one of your values is incorrect.
|
|
|
|
|
cchTextMax = sNodeName.size()
Kuphryn
|
|
|
|
|
Wow... how did i miss that
|
|
|
|
|