|
After Going through ur post 3 times and then figuring out that teh actually means the
This might Help
Everytime you have to Modify one Object you will have to search the whole list and find the one which you want to Modify
POSITION pos = list.GetHeadPosition();
for (int i=0;i < list.GetCount();i++)
{
Chan *pChan = list.GetNext(pos);
if(pChan->name == "STRING TO TEST")
{
}
}
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Hi!
I've created a SDI application with the new CHtmlEditView and CHtmlEditDoc classes for my document/view.
In my derived CHtmlEditView class, I have overrided functions OnKillFocus and OnChar to intercept the WM_CHAR and WM_KILLFOCUS messages.
But my view (and my main frame) doesn't got theses messages.
How to intercept this kind of messages in a such document/view type? Is there any special thing to add, in order to intercept theses messages in an HtmlEdit control?
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
Post the code that specifies the program wants to handle those messages in the view and main frame classes.
It is very possible to handle those messages in both the view and main frame.
Kuphryn
|
|
|
|
|
Thks! But with the code added in both the view and the main frame, I don't receive the WM_CHAR message.
Here is my code from my CView and CMainFrame classes:
<br />
<br />
#include "stdafx.h"<br />
#include "Focus3.h"<br />
<br />
#include "MainFrm.h"<br />
#include ".\mainfrm.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
<br />
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)<br />
<br />
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)<br />
ON_WM_CREATE()<br />
ON_WM_CHAR()<br />
ON_WM_KILLFOCUS()<br />
END_MESSAGE_MAP()<br />
<br />
static UINT indicators[] =<br />
{<br />
ID_SEPARATOR, <br />
ID_INDICATOR_CAPS,<br />
ID_INDICATOR_NUM,<br />
ID_INDICATOR_SCRL,<br />
};<br />
<br />
<br />
.....<br />
<br />
void CMainFrame::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)<br />
{<br />
AfxMessageBox ("OnChar");<br />
<br />
CFrameWnd::OnChar(nChar, nRepCnt, nFlags);<br />
}<br />
<br />
...<br />
and my CView class:
<br />
<br />
#include "stdafx.h"<br />
#include "Focus3.h"<br />
<br />
#include "Focus3Doc.h"<br />
#include "Focus3View.h"<br />
#include ".\focus3view.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
<br />
IMPLEMENT_DYNCREATE(CFocus3View, CHtmlEditView)<br />
<br />
BEGIN_MESSAGE_MAP(CFocus3View, CHtmlEditView)<br />
ON_COMMAND(ID_FILE_PRINT, CHtmlEditView::OnFilePrint)<br />
ON_WM_SETFOCUS()<br />
ON_WM_KILLFOCUS()<br />
ON_WM_CHAR()<br />
END_MESSAGE_MAP()<br />
<br />
BEGIN_DHTMLEDITING_CMDMAP(CFocus3View)<br />
DHTMLEDITING_CMD_ENTRY(ID_EDIT_COPY, IDM_COPY)<br />
DHTMLEDITING_CMD_ENTRY(ID_EDIT_CUT, IDM_CUT)<br />
DHTMLEDITING_CMD_ENTRY(ID_EDIT_PASTE, IDM_PASTE)<br />
DHTMLEDITING_CMD_ENTRY(ID_EDIT_UNDO, IDM_UNDO)<br />
END_DHTMLEDITING_CMDMAP()<br />
<br />
<br />
......<br />
<br />
void CFocus3View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)<br />
{<br />
AfxMessageBox ("OnChar");<br />
<br />
CHtmlEditView::OnChar(nChar, nRepCnt, nFlags);<br />
}<br />
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
Who can tell me how to derive a class from ScrollBar, then this class can have a image interface?
If anybody can give me a example, i will feel very lucky.
Thank you very much.
|
|
|
|
|
Might just come in Handy
Click ME[^]
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
hello everybody,
here is a problem..
how to enumerate the name & it's IP addresses of devices(both Input & Output) in the personal system as well as to the network using WIN32 APIs & VC++ ???
if any body have snipet of code ,please give ...
thanking
skpanda
|
|
|
|
|
hello sir,
here is the bit clarification what i need actually.
i have to enumerate all the devices(both input as well as output devices) like printer,cdrom,flopy disk,monitor,keyboard,mouse etc... .with all the network resources like switch,modem,router...etc...
i have to enumerate these with IP address or without ...if it is not available with name .so please carify which win32 api function is suitable to this...please inform me earlier...
here r some function which i have gone through msdn
wnetenumresource
WNetOpenEnum
shall i use these...
if yes how just give me a snipet of code ....
waiting
skpanda
|
|
|
|
|
is the function call in main correct ???
please rectify it...
// iodevices.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "windows.h"
#include "Winnetwk.h"
//#include "display.h"
BOOL WINAPI NetErrorHandler(HWND hwnd,
DWORD dwErrorCode,
LPSTR lpszFunction);
BOOL WINAPI EnumerateFunc(HWND hwnd,
HDC hdc,
LPNETRESOURCE lpnr);
int main(int argc, char* argv[])
{
// NETRESOURCE nr;
EnumerateFunc(NULL,NULL,NULL);
return 0;
}
BOOL WINAPI NetErrorHandler(HWND hwnd,
DWORD dwErrorCode,
LPSTR lpszFunction)
{
DWORD dwWNetResult, dwLastError;
CHAR szError[256];
CHAR szCaption[256];
CHAR szDescription[256];
CHAR szProvider[256];
// The following code performs standard error-handling.
if (dwErrorCode != ERROR_EXTENDED_ERROR)
{
wsprintf((LPSTR) szError, "%s failed; \nResult is %ld",
lpszFunction, dwErrorCode);
wsprintf((LPSTR) szCaption, "%s error", lpszFunction);
MessageBox(hwnd, (LPSTR) szError, (LPSTR) szCaption, MB_OK);
return TRUE;
}
// The following code performs error-handling when the
// ERROR_EXTENDED_ERROR return value indicates that the
// WNetGetLastError function can retrieve additional information.
else
{
dwWNetResult = WNetGetLastError(&dwLastError, // error code
(LPSTR) szDescription, // buffer for error description
sizeof(szDescription), // size of error buffer
(LPSTR) szProvider, // buffer for provider name
sizeof(szProvider)); // size of name buffer
//
// Process errors.
//
if(dwWNetResult != NO_ERROR) {
wsprintf((LPSTR) szError,
"WNetGetLastError failed; error %ld", dwWNetResult);
MessageBox(hwnd, (LPSTR) szError,
"WNetGetLastError", MB_OK);
return FALSE;
}
//
// Otherwise, print the additional error information.
//
wsprintf((LPSTR) szError,
"%s failed with code %ld;\n%s",
(LPSTR) szProvider, dwLastError, (LPSTR) szDescription);
wsprintf((LPSTR) szCaption, "%s error", lpszFunction);
MessageBox(hwnd, (LPSTR) szError, (LPSTR) szCaption, MB_OK);
return TRUE;
}
}
BOOL WINAPI EnumerateFunc(HWND hwnd,
HDC hdc,
LPNETRESOURCE lpnr)
{
DWORD dwResult, dwResultEnum;
HANDLE hEnum;
DWORD cbBuffer = 16384; // 16K is a good size
DWORD cEntries = -1; // enumerate all possible entries
LPNETRESOURCE lpnrLocal; // pointer to enumerated structures
DWORD i;
//
// Call the WNetOpenEnum function to begin the enumeration.
//
dwResult = WNetOpenEnum(RESOURCE_CONNECTED, // all network resources
RESOURCETYPE_ANY, // all resources
0, // enumerate all resources
NULL, // NULL first time the function is called
&hEnum); // handle to the resource
if (dwResult != NO_ERROR)
{
//
// Process errors with an application-defined error handler.
//
NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetOpenEnum");
return FALSE;
}
//
// Call the GlobalAlloc function to allocate resources.
//
lpnrLocal = (LPNETRESOURCE) GlobalAlloc(GPTR, cbBuffer);
do
{
//
// Initialize the buffer.
//
ZeroMemory(lpnrLocal, cbBuffer);
//
// Call the WNetEnumResource function to continue
// the enumeration.
//
dwResultEnum = WNetEnumResource(hEnum, // resource handle
&cEntries, // defined locally as -1
lpnrLocal, // LPNETRESOURCE
&cbBuffer); // buffer size
//
// If the call succeeds, loop through the structures.
//
if (dwResultEnum == NO_ERROR)
{
for(i = 0; i < cEntries; i++)
{
// Call an application-defined function to
// display the contents of the NETRESOURCE structures.
//
// DisplayStruct(hdc, &lpnrLocal[i]);
// If the NETRESOURCE structure represents a container resource,
// call the EnumerateFunc function recursively.
if(RESOURCEUSAGE_CONTAINER == (lpnrLocal[i].dwUsage
& RESOURCEUSAGE_CONTAINER))
if(!EnumerateFunc(hwnd, hdc, &lpnrLocal[i]))
TextOut(hdc, 10, 10, "EnumerateFunc returned FALSE.", 29);
}
}
// Process errors.
//
else if (dwResultEnum != ERROR_NO_MORE_ITEMS)
{
NetErrorHandler(hwnd, dwResultEnum, (LPSTR)"WNetEnumResource");
break;
}
}
//
// End do.
//
while(dwResultEnum != ERROR_NO_MORE_ITEMS);
//
// Call the GlobalFree function to free the memory.
//
GlobalFree((HGLOBAL)lpnrLocal);
//
// Call WNetCloseEnum to end the enumeration.
//
dwResult = WNetCloseEnum(hEnum);
if(dwResult != NO_ERROR)
{
//
// Process errors.
//
NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetCloseEnum");
return FALSE;
}
return TRUE;
}
skpanda
|
|
|
|
|
Pande ji ,
try this
Click ME[^]
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
hello monty sir,
Click Me[^] is not working ...
please give the url correctly and please tell me how to enumerate all input /output devices in a network as well as local computer ...where the application is running...
waiting your response now ...
skpanda
|
|
|
|
|
|
hello,
but i want to enumerate all network resources, like SWITCH,ROUTER connected , etc....how to do that ??any idea ??
please guide...
thanking u ...
skpanda
|
|
|
|
|
I use below code:
HWND hdesk = ::FindWindow("Progman", NULL);
hdesk = ::FindWindowEx(hdesk, 0, "SHELLDLL_DefView", NULL);
hdesk = ::FindWindowEx(hdesk, 0, "SysListView32", NULL);
HIMAGELIST hImageList = (HIMAGELIST)::SendMessage(hdesk, LVM_GETIMAGELIST, 0, 0);
but the hImageList count always return 0, why?
|
|
|
|
|
Thanks buddy. but a small problem i couldn't get "drw_dxf.h" which U've included.
awaiting Ur reply
|
|
|
|
|
Im working on app that will keep lists of things in a ini file from edit boxes on a dialogs.
I already know about CEdit and WritePrivateProfileStrings things.
but I need things to be listed like this. also I will add ability to delete.
mIRC does this same way with the servers.ini and alias.ini
[thing]
n0=here
n1=food
n2=metal
n3=hotdogs
n4=metals
n5=pencils
n6=pens
n7=paint
for your info. Im using MFC to make my program in Visual C++ 6.0.
here is my example of program
http://adamc.hypermart.net/TESTSTRINGS.zip
|
|
|
|
|
Not sure I understand, why is WritePrivateProfileString() insufficient for your app? The INI file looks like you describe, and WritePrivateProfileString() can delete entries or whole sections.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
http://adamc.hypermart.net/TESTINI.zip
here is my app
my friend told me to use loop in that testini() section.
it do not work.
look for this section.
void CINIFileTestDlg::OnTestini()
{
// TODO: Add your control notification handler code here
char sIniFile[MAX_PATH];
GetModuleFileName( NULL, sIniFile, MAX_PATH );
strcpy( strrchr( sIniFile, '\\' ) + 1, "TESTTT.ini" );
char buffer[1024];
///for(int x=0; x < GetnCount(); ++x)
for(int x=0; x < GetnCount(); ++x)
{
sprintf(buffer,"n%d",x);
WritePrivateProfileString("TEST", buffer, "STRING", sIniFile);
}
m_ncount++;
|
|
|
|
|
Ok. I am assuming that in your OnTestini() method, you want to READ from the .INI file, to test out the fact that it was created?
So, if that is the case. What you need to do is a call to GetPrivateProfileString(). That will read the .INI file for you and populate a variable.
It appears as though you are using a class that someone else created to do your Write/Get to the .INI file. If you are trying to do a basic .INI file, this is unnecessary because you can use the built in methods GetPrivateProfileString() and WritePrivateProfileString() yourself to do the task!
So, first off, lets take the code that you have now, and make a little modification to the OnTestini() method. Lets make this method actually read values from the .INI file. I am adapting this so it looks just like your current code. How this works is this. You run your app. Type in c:\test.ini in the filename.ini editbox (You must use a relative path or GetPrivateProfileString() may fail depending on where it gets run from). Type in something for the section/name and value fields. Then, press MAKE INI. It will create c:\test.ini for you. (That part in your code worked OK). Next, if you want to be sure, delete out the value that you typed in for the key value. Then, press TEST INI button. What happens is the following code figures out which key you want from your editboxes and then tries a GetPrivateProfileString() to get that data for you. (And it will succeed too!). It'll then give you a MessageBox with the key value. The code modification is below...
Also, what I would recommend is doing something like this. Start a new MFC dialog based app. Add a test ini and a make ini button along with your edit boxes. After you've created the editboxes, right click anywhere on the dialog you are creating, and select ClassWizard from the menu that pops up. Then, click on the Member Variables Tab. Scroll down to your IDC_EDIT1 and click on Add Variable. It'll ask for the member variable name, type something in there like m_fileName. Leave the default values in there for the rest (Category: Value and Variable Type: CString) Then, do that for each of your editboxes, do some variables like m_secName, m_keyName, m_keyValue. Once you do that, you can then access m_fileName,m_secName,m_keyName,m_keyValue from any member method of your class. So currently you have things like this:
CEdit* getsection = (CEdit*)GetDlgItem(IDC_EDIT7);
getsection->GetWindowText(putsection);
MessageBox(putsection); // Shows whatever was in IDC_EDIT7 edit box
If you do what I am suggesting, you can then do this in your code.
UpdateData(TRUE); // Do this ONCE before you try to access this variable.
MessageBox(m_keyName); // Shows whatever was in that edit box!
Then, once you have that in place, you can create your INI file like this
WritePrivateProfileString(m_secName,m_keyName,m_keyValue,m_fileName);
Then, when you want to read a value:
char buf[80];
GetPrivateProfileString(m_secName,m_keyName,"A DEFAULT VALUE",buf,80,m_fileName);
MessageBox(m_keyName + " in the ini file has a value of " + buf);
It's as simple as that! The "A DEFAULT VALUE" is a default value to use in case the read failed. (IE It can't find the section or key that you are looking for, so it returns a default value)
Drop a line if something does not make sense. Hopefully I explained it enough!
-Shultas
void CINIFileTestDlg::OnTestini()
{
// TODO: Add your control notification handler code here
char buffer[1024];
char sIniFile[MAX_PATH];
CEdit* getfilename = (CEdit*)GetDlgItem(IDC_EDIT1);
CString putfilename;
getfilename->GetWindowText(putfilename);
CEdit* getsection = (CEdit*)GetDlgItem(IDC_EDIT7);
CEdit* getname = (CEdit*)GetDlgItem(IDC_EDIT2);
CString putsection;
CString putname;
char myBuf[80];
getsection->GetWindowText(putsection);
getname->GetWindowText(putname);
//WritePrivateProfileString(putsection,putname,"key value here","test.ini");
GetPrivateProfileString(putsection,putname,"default value",myBuf,80,putfilename);
MessageBox(myBuf);
}
|
|
|
|
|
Please again check out my new program....
there is problem with loop ;/
it should only do that thing ONE time each time you press 'add string' button.
at this time im not using anyone's class.
http://adamc.hypermart.net/TESTSTRINGS.zip
|
|
|
|
|
Okie. I had a look and I see the problem. First off, what exactly is it that you are trying to do with your program? Then I can be direct and show you the code necessary.
For now, I'll show you what is wrong with the loop.
Here's your code:
int m_ncount = 1;
CString KeyName;
for(int x=0; x < m_ncount; ++x)
{
KeyName.Format("n%ld", x);
///WritePrivateProfileString("TEST", buffer, putstring, sIniFile);
WritePrivateProfileString("TEST", KeyName, putstring, sIniFile);
m_ncount++;
}
If you look carefully, you will see the reason your program locks up is because you have created an infinate loop! The condition "x < m_ncount" will never be true, because you are incrementing the m_ncount variable at the end of the loop! So, the first time that the loop runs,
m_ncount=1 and x=0. The second pass, m_ncount=2; x=1 ... Third pass, m_ncount=3;x=2. So each pass, the variable x gets incremented and so does the variable m_ncount! So therefore the loop will run forever!
Post back and let me know what you are trying to do and I'll throw something together for you real fast to take example of!
Shultas
|
|
|
|
|
Im trying to make it increament the strings like this each time you press the button.
n0=string1
n1=string2
n2-string3
n3=string4
I know what problem im having ;/
Im not sure how to do it right way.
|
|
|
|
|
Okay. Gotcha.
What I would do is this. Open up your classview and add a new member to the declaration of your CTESTINI2Dlg.
class CTESTINI2Dlg : public CDialog
{
.......
.......
protected:
HICON m_hIcon;
int topKeyValue; // <------ Add this in there
Then, expand the view for the CTESTINI2Dlg. Double click on the OnInitDialog() method.
Look for the following lines (at the end of this method)
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
topKeyValue = 0; // <----------- Add that in there
Then, double click on your OnAddStrings() method. This should go in there INSTEAD of the for{} loop. Get rid of that loop.
void CTESTINI2Dlg::OnAddstrings()
{
char sIniFile[MAX_PATH];
GetModuleFileName( NULL, sIniFile, MAX_PATH );
strcpy( strrchr( sIniFile, '\\' ) + 1, "strings.ini" );
CEdit* getstring = (CEdit*)GetDlgItem(IDC_EDIT4);
CString putstring;
getstring->GetWindowText(putstring);
CString KeyName;
topKeyValue++;
KeyName.Format("n%ld", topKeyValue);
WritePrivateProfileString("TEST", KeyName, putstring, sIniFile);
MessageBox("Added...");
}
Okay. What this does is add an integer variable to your CTESTINI2Dlg class named topKeyValue. Then, in your OnInitDialog() code, topKeyValue = 0; that is initializing it to 0 when the program starts up. Then, in your OnAddstrings() method, topKeyValue++ increments the member variable by one, formats it in the KeyName.Format string, and writes that number accordingly. Each time you press the add strings button, topKeyValue gets incremented by 1, thus allowing you to write a new line into the file!
So, what are you trying to do, screw with someones MIRC INI files?
|
|
|
|
|
[quote] So, what are you trying to do, screw with someones MIRC INI files? [/quote]
Nope
Im working on making my own irc client.
thats why Im trying to figure out those stuff.
|
|
|
|
|
Im trying to build same application as Zion mirc editor
http://adamc.hypermart.net/Zion.zip
look carefully and see how it does with writing and saving ini files.
I know its in spanish ? but you can understand how the program works.
I think its MFC app.
I cant find source codes of similar programs.
|
|
|
|
|