|
how are you creating the thread ?
|
|
|
|
|
I find the reason.
When I call the AfxBeginThread in MFC driven class constructores I see this problem.
but when I call it in another function, I dont see this problem.
|
|
|
|
|
I find the reason of this error.
When I call AfxbeginThread in MFC class constructures, I see this problem.
|
|
|
|
|
Hi all
i have developed a web server. Whenever a client connect to my web server, i create a thread and process the rquest. In my thread, each time i create one COM component(Script engine vbscript.dll)using CoCreateInstance. so i am facing a problem while calling the CoCreateInstance().
Is any good method to avoid frequent calls to the COM component. I mean
one time initializing my engine and using it whenever i need
thanks
g.shadrach
|
|
|
|
|
why not use this way
CoGetClassObject(rclsid, dwClsContext, NULL, IID_IClassFactory, &pCF);
hresult = pCF->CreateInstance(pUnkOuter, riid, ppvObj)
pCF->Release();
just to call
CoGetClassObject(rclsid, dwClsContext, NULL, IID_IClassFactory, &pCF);
first time it will ensure the dll loading.
then whenever you want to create an instance just call
hresult = pCF->CreateInstance(pUnkOuter, riid, ppvObj)
|
|
|
|
|
OK. i will change my code and let me see
|
|
|
|
|
Hi, i've created a droplist combo box, and listed a few item. Are there anyone who know how to link the clicked item to a certain file saved in text format. I'll then need to send the file to hardware after clicking on the ok button in the dialog box. This is some code that i found in this site. It just shows to get the selection from the droplist. In my dialog box i've created a function to open,browse and load the file. Now i need to figure out how to write the code to automatically link the clicked item in the droplist to a certain text file and also display it in the other function(open,browse and load the file). Also, each item listed in the droplist correspond to different text file. Is there any suggestion on what codes i should add? Is there any article or example that i can refer to? i'm a begineer here.
void CComboBoxTutorialDlg::OnDropListSelchange()
{
UpdateData();
if( m_nDropListIndex < 0 ) return;
CString str;
m_DropList.GetLBText( m_nDropListIndex, str );
CString Out;
Out.Format( "Drop List Selection => index %d\n%s", m_nDropListIndex, str );
AfxMessageBox( Out );
}
thanks in advance
|
|
|
|
|
it is better to divide your problem in parts.
1:get selection from combo box
for this you should handle the notification ON_CBN_SELCHANGE
in this handler get the selection with GetLBText()
2: how to relate data
For this purpose you can use GetItemData() and SetItemData()
or GetItemDataPtr() and SetItemDataPtr()
|
|
|
|
|
cyn8 wrote: UpdateData();
if( m_nDropListIndex < 0 ) return;
What is this supposed to do?
Try:
int nIndex = m_DropList.GetCurSel();
m_DropList.GetLBText(nIndex, str);
...
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
In MFC we can choose SDI, MDI or Dialog based application to create but in Win API I don't know how to create SDI application like NodePad. Please answers to me soon.
Thanks.
|
|
|
|
|
In Win32 API we usualy use the CreateWindow() function and WinProc() function to process messages
here is an example of Single Document Interface (I took this piece of code from my recent project )
/*************************
The framework for any
Single-Document-Interface
application
**************************/
//////////////////////////////
// #include
//////////////////////////////
/* windows.h contains *all* of
the things we need for this demo */
#include "windows.h"
//////////////////////////////
// #define
//////////////////////////////
//////////////////////////////
// prototypes
//////////////////////////////
/* this is the prototype for our Window
Procedure: it is called by Windows (the O/S)
(hence the CALLBACK) and it returns a
LRESULT (long). It's parameters are a
HWND (handle to a window), a UINT (unsigned integer,
which represents the message), a WPARAM
(a special unsigned integer that contains extra
information about the message being sent) and finally
a LPARAM (a special long which also contains information
about the messge being sent) */
LRESULT CALLBACK WinProc(HWND, UINT, WPARAM, LPARAM);
//////////////////////////////
// globals
//////////////////////////////
/* in this example, szAppName is the windows title.
The TCHAR is an unsigned short and is necessary for
portability between Windows 9x and Windows NT. The same
is true for the TEXT() macro, which could be replaced
by a lot of things, eg: _T() or __T() or T() */
TCHAR szAppName[] = TEXT("SDI Frame");
/* the szWinClass is necessary later when we register
the window class */
TCHAR szWinClass[] = TEXT("WIN_CLASS");
//////////////////////////////
// WinMain(...)
//////////////////////////////
/* the WinMain(...) function is the entry point
for all Win32 API programs (except MFC). It is the
Windows equivalent of main(...).
It returns an integer value and the WINAPI could
have been PASCAL or any other equivalent calling-convention.
It's parameters are two instances (the first one is the
current instance and the second one is the now obsolete
previous instance, which is no longer used), a command-line
(how to deal with this is in the next tutorial) and an
integer dictating how to show the window (either Maximised or
Minimised) */
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR lpCmdLine,
int nCmdShow)
{
MSG msg; // a struct used in the passing of messages
WNDCLASS wc; // a window class struct, see below
HWND hwnd; // a handle-to-a-window, see below
/* the window class struct is the first step in setting up
a window. all of the attributes are set before the class is
registered. Each window class can be used to create more than
one window. Also, there are predefined controls that have their
own class and, as you will see, their own Window Procedure. These
controls include: Edit Boxes, Combo Boxes, Scroll Bars, etc. */
wc.cbClsExtra = 0; // specify how many bytes extra space is required for every window derived from this window class
wc.cbWndExtra = 0; // specify how many bytes extra space is required for this window
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); // background colour
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // cursor, this is usually the default
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // icon, this can be changed using resources (shown in the next tutorial)
wc.hInstance = hInstance; // the current instance of the program is passed to the instance of the class
wc.lpfnWndProc = WinProc; // the window procedure used by this class, usually has a more distinguishing name
wc.lpszClassName = szWinClass; // the name of this class
wc.lpszMenuName = NULL; // the name of the menu to be attached to the window, null until next tutorial
wc.style = CS_HREDRAW | CS_VREDRAW; // these 'class styles' mean that the window will be redrawn whenever it is resized vertically or horizontally
if( !RegisterClass(&wc)) // register the class, and test if it fails
{
MessageBox(NULL, TEXT("Error registering class"), TEXT("ERROR"), MB_OK);
return 0;
}
hwnd = CreateWindow(szWinClass, // the class as specified in the one we just registered
szAppName, // the title of the window
WS_OVERLAPPEDWINDOW, // the window style (there are usually a lot more of these
CW_USEDEFAULT, // the left co-ord of the window
CW_USEDEFAULT, // the top co-ord of the window
CW_USEDEFAULT, // the width of the window
CW_USEDEFAULT, // the height of the window
(HWND) NULL, // a handle to the parent window
(HMENU) NULL, // a handle to the window's menu
(HINSTANCE) hInstance, // the instance of the window (which is the instance of the app)
(void *) NULL); // any extra information (I think it is passed to the window when it is created in the lParam of the WM_CREATE message?)
// WM_CREATE message has been sent to the window
ShowWindow(hwnd, nCmdShow); // shows the window, using the specified command (Maximised, Minimised, etc)
UpdateWindow(hwnd); // the window is updated (a WM_PAINT message is sent to the window
while (GetMessage(&msg, (HWND) NULL, 0, 0)) // while there is a message to retrieve, and that message is not WM_QUIT
{
TranslateMessage(&msg); // some messages need translating
DispatchMessage(&msg); // send the message to the window
}
return msg.wParam; // return the message struct's wParam
}
//////////////////////////////
// WinProc(...)
//////////////////////////////
/* every window must have a function that Windows (the O/S) calls.
It uses a switch statement to test which message it is receiving */
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_PAINT:
/* the following two lines are the minimum
that has to be done for every program */
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
/* between those two lines you could have
outputted text etc. */
return 0;
case WM_DESTROY:
/* if the quit message is not posted then the while
that we created in WinMain(...) will not quit and the
application will disappear from view but will still be
resident in memory */
PostQuitMessage(0);
break; // pass to DefWindowProc(...) as well
}
/* takes care of all of the messages that we didn't catch
in our Window Procedure */
return DefWindowProc(hwnd, msg, wParam, lParam);
}
---
-- modified at 18:19 Saturday 4th November, 2006
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
John von Neumann
|
|
|
|
|
Hi,
I'm looking for a way to change the internet settings programaticly so i used many WIN32 APIs such as WININET and RAS ,I found that the second method work easily by filling the RASDIALPARAMS
structure but with only phone line connection (means that we can not use adsl modem) whereas
the first method appears difficult or its not clear for me .
Could someone give me an exemple to change all settings connection (time out, Number of retries..ext) with WININET APIs or another method if exist
Thanks
---
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
John von Neumann
|
|
|
|
|
hi i need help since im new to device interfacing
i wanted to create my own application using a particular device and i dont knw where to
start(where to i begin create a com?enumerate the device?need help)
this device in particular is a color calibrator device.
|
|
|
|
|
|
thanks but im not building yet a device driver...the device im using contains already a driver all I want to knw is how to implement that driver ive already tried using #import directive then createinstance when I try to use it it says class not registered....so where do i go from there need directions?
|
|
|
|
|
The article uses some key words you could use in your quest. Anyway, I don't think your application will work directly with the driver. Also, you probably need specific information on how to communicate with it once you establish a connection.
|
|
|
|
|
Hi,
hardware designers and driver developers require unique implementation tips and tools for ensuring reliability and good performance but I suggest you to use DDk (Windows Driver Development Kit) this tool which is header and library files included .
for further infos go to www.microsoft.com/whdc/driver/default.mspx for driver Fundamentals
---
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
John von Neumann
|
|
|
|
|
I created a dialog based application, and created a new class.
The new class has a member function SubFunc(), in which i want to output a value to a CEdit control on the dialog. How to implement this.
Thanks
Flex
|
|
|
|
|
m_MyEdit.SetWindowText(_T("Edit Text"));
|
|
|
|
|
Define a class member variable that hold a pointer to dialog, then access CEdit through that member.
|
|
|
|
|
how to assign exeName1 to processname[0]
CHAR exeName1[15];
static char ** ProcessName;
ProcessName = new char*[2];
GetPrivateProfileString ("AC", "exe1","", exeName1, 50,"C:\\exe1.ini");
ProcessName[0] = exeName1; //// giving error
can u please help me
Thanks
abhi
|
|
|
|
|
ProcessName is a pointer to a pointer.
Right now, it points to an array of two char *s. You probably want to do this:
static char ** ProcessName;
ProcessName = new char*[2];
ProcessName[0] = new char[15];
ProcessName[1] = NULL; //Until it gets a real value.
::memset(ProcessName[0], 15, 0); // Possibly change the 0 and 15, can't recall.
GetPrivateProfileString ("AC", "exe1","", ProcessName[0], 50,"C:\\exe1.ini");
What does the second char * in the array point to ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
abhiramsss wrote: ProcessName[0] = exeName1; //// giving error
There are 2 problems here. First, your array is an array of 2 character pointers, so when you set exeName1 to ProcessName[0], you are just setting the pointer value to point to that. The problem is that, since exeName is on the stack, it's type is char[] and not char* (slight, but important difference). Also, since it is on the stack, when it goes out of scope, that pointer is no longer valid anyway (so you would have a dangling pointer). What I believe you want to do is:
static char** ProcessName = new char*[2];
memset(ProcessName, 0, sizeof(char*) * 2);
ProcessName[0] = new char[15];
memset(ProcessName[0], 0, sizeof(char) * 15);
GetPrivateProfileString("AC", "exel", "", ProcessName[0], 14, "C:\\exe1.ini");
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
is it possible to check a checkbox in the remote application?
if it is, please some hints, how?
etc.: if windows calculator has Hyp and Inv checkboxes and i need to check one, how to do that?
thank you in advance for any help while(1==1) write( );
|
|
|
|
|
I'm not sure how you would grab the handle of an object in another application window ... It may be possible, But if that does no work...
Mabey you can find out the window cords of the other window. Then move the mouse to the location of the box and simulate a click.. I've seen some applications do stuff like that, And I can only figure it was the only thing they could come up with to get the job done... But I'm still a seasoned noob.. So I don't really know... Just a thought..
Let me know what you come up with.. Controlling other apps would be a nice thing to know. Good luck..
|
|
|
|
|