|
The class keyword shouldn't be required. Also the way you do it creates a copy of the _Wordsheet parameter. Using a reference would be better. i.e.
void OutputFunction(const _Worksheet &sheet)
You may need to remove the const depending on what operationa are performed in the function.
Steve
|
|
|
|
|
|
Hi All,
I've to create an application container that hosts different dialog
based applications. Each dialog based application should be loaded based on certain criteria. Basically combining several independent dialog based applications into one application.
Any insights would be greatly appreciated.
Thanks,
|
|
|
|
|
Why not just host multiple dialog boxs in the same app. What do you gain by creating multiple dialogs applications and duct taping them together in another application?
Anyway, you could use _spawnlp or ShellExecuteEx
|
|
|
|
|
Thanks Bob, I'll take a look at ShellExecuteEx
|
|
|
|
|
Hi all.
I'm very new to Visual C++, so I apologize in advance if I miss any important details.
I'm trying to create a unbound DataGridView object that comes with a (small) predefined number of entries and a few unmodifiable default entries. This I've been able to do just fine.
My problem comes with sorting. I'd like to allow the user to sort the entries that he's added himself when he clicks the column header:
For example, if I have 10 rows, 3 of which are predefined as "1", "apple", and "2".. and the user enters "hi", "a", and "there" into the next few rows, I'd want the following sort results:
1,apple,2,a,hi,there,(empty),...,(empty)
1,apple,2,there,hi,a,(empty),...,(empty)
when sorting in forward and reverse order, respectively.
My first attempt after looking through the MSDN docs was to create a SortCompare Event Handler, but apparently my attempts to hardcode this sort of functionality in with things like
e->SortResult = e->RowIndex1 - e->RowIndex2;
conflicts with the quicksorting algorithm the class uses, and causes all sorts of weird behavior and ArrayOutOfBounds errors.
Have I overlooked anything? What's the best strategy to approach this sort of problem?
Any suggestions are appreciated, just let me know if you need more information.
|
|
|
|
|
Hi guys,
I would appreciate if someone could tell me "How to add selected item from one listbox to another"?
I have 2 list boxes. While I execute my application, I select some items from one and some from another. Now, if one data item is not in another, I want to add that item to the list box.
Thanks in advance
C++Prog
|
|
|
|
|
like this
CString str;
m_ListBox1.GetText(m_ListBox1.GetCurSel(),str);
m_ListBox2.AddString(str);//or InsertString
whitesky
|
|
|
|
|
Thanks for your great help..but I don't know it is giving me errors like:
left of '.GetText' must have class/struct/union type
Thanks again
C++Prog
|
|
|
|
|
Preeti9 wrote: left of '.GetText' must have class/struct/union type
Which is telling you that m_ListBox1 must be a CListBox object.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
|
I've recently converted my VS6 project to 2005 and the problem I'm now getting is that my open/save dialogs aren't opening at all. ie) I have a file import dialog that was working, but is now not being displayed at all. My class is derived from CFileDialog. The section of code this seems to be failing in is:
in dlgfile.cpp
CFileDialog::DoModal()
{
...
INT_PTR nResult;
if (m_bOpenFileDialog) (true)
nResult = ::AfxCtxGetOpenFileName(&m_ofn);
...
}
from this nResult is 0. from there is returns a IDCANCEL due to nResult being 0.
I can step into this call, where it goes to:
OPENFILENAME& CFileDialog::GetOFN()
{
return *m_pOFN;
}
m_pOFN seems to be a valid structure, although most of the data seems to be defaults with some empty pointers.
Anyone have any thoughts on what might cause this to return false/0?
I can't seem to find any documentation on AfxCtxGetOpenFileName ().
Thanks for your help.
|
|
|
|
|
Hi,
How can i distinguish between Excecute Key and + Key while both having the same pMsg->wParam = 0x0000002b.
Any body having an idea pls tel me.
yours faithfully
ajeesh c v
|
|
|
|
|
Ajeesh c v wrote: How can i distinguish between Excecute Key...
What's this?
Ajeesh c v wrote: ...and + Key
Is this the VK_ADD key?
"The largest fire starts but with the smallest spark." - David Crow
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Ajeesh c v wrote: How can i distinguish between Excecute Key and + Key while both having the same pMsg->wParam = 0x0000002b.
Any body having an idea pls tel me.
What is Execute Key, have you check the value of lParam!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Help CRY
|
|
|
|
|
I am making a custom control that can recieve some datas and verify the datas recieved.
The custom control(suppose it is named CDataVerify) is inherited from Cwnd and it contains three CEdit controls.The design is when the focus leaves the CDataVerify, it(CDataVerify) should verify the values of thethree CEdit control.
Now the problem comes, when the focus leaves the CDataVerify control,how can the CDataVerify control know the focus lose and should verify the datas?
(At first I think the onKillFocus() event maybe resolve the problem. But it can not, for the CDataVerify control never got the focus. When typing something to the contained CEdit control, the focus just belongs to the CEdit control, not the CDataVerify.)
Is there any way to let the CDataVerify control verify datas when the focus leaves?
//////////////////////////////
-- modified at 21:27 Thursday 25th May, 2006
|
|
|
|
|
willbin wrote: (At first I think the onKillFocus() event maybe resolve the problem. But it can not, for the CDataVerify control never got the focus.
But did the edit controls themselves receive the WM_KILLFOCUS message?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Thank you.
of course, yes. The edit controls recieve the WM_KILLFOCUS message. But the edit control recieved the WM_KILLFOCUS message only can deal with the data itself held. It do not know the value of its siblings. The Parent knows, but the parent has't the focus(Can not recieve the WM_KILLFOCUS message when the focus leaves.)
//////////////////////////////
A stranger , also a challenger
|
|
|
|
|
So can you handle WM_KILLFOCUS for the edit controls, and get them to send a message to their parent which triggers the data verification?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thank you.Notify the parent(CDataVerify) to do data verification in spite of wether or not the focus will be still setted to his parent.
Maybe not good enough, but it really resolves problem.
Thank Ryan.
//////////////////////////////
A stranger, also a challenger
|
|
|
|
|
willbin wrote: But the edit control...do not know the value of its siblings.
Nor should it. Each control should take care of itself.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hi,
I'm learning how to insert a button into another application's window using c programming. In short, I wrote an EXE file which modified a particular Window of another EXE file to insert a button in that window. Need some advice:
a. I was able to get to the other application's window by first hooking onto the other application's window handle. But the strange thing is that my callback function for WM_LBUTTONDOWN of my introduced button was not called when I click on the inserted button. Instead, I had to do a GetMessage in my main program to get the message for the button and check the message member in there. With this, I was able to insert an extra button into a messagebox in another EXE file while it's running.
b. What I don't quite understand is that when I try to use the same technique on different windows, I get different errors. For instance, if I were to insert a button this way into a .NET window, the button shows up as a white patch. It responds to the click though. For some other programs, my button crashed without inserting itself. Puzzled by the different behaviour. Is it due to the windows message queue and the different nature of windows that I'm getting this?
c. Strangely, although my callback WinProc function is not called when I click on the button, not defining the WinProc actually causes my program to die when attaching itself to any window that's not a messagebox. Not quite sure why.
If someone can guide me to any article on how to insert controls into another app's windows or to understand the windows message loop more, I would be grateful. I'm trying to do a little enhancement to a program whose source code is lost (ie, I only have the binary).
My code looks like this:
#include
#include
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
int WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,int)
{
HWND hWnd, hwndButton;
WNDCLASS wc;
MSG msg;
// Trace Windows Handle based on Name
hWnd = (HWND) 0x1D0458;
printf("Begin Program\n");
wc.style=CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc=WindowProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInst;
wc.hIcon=NULL;
wc.hremoved=NULL;
wc.hbrremoved(HBRUSH)COLOR_WINDOWFRAME;
wc.lpszMenuName=NULL;
wc.lpszClassName="BUTTON";
if (!RegisterClass(&wc)) return 0;
printf("Finished Creating Button");
hwndButton = CreateWindow(
"BUTTON", // predefined class
"H", // button text
WS_VISIBLE | WS_CHILD , // styles
// Size and position values are given explicitly, because
// the CW_USEDEFAULT constant gives zero values for buttons.
950, // starting x position
0, // starting y position
20, // button width
20, // button height
hWnd, // parent window
NULL, // No menu
(HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
NULL); // pointer not needed
if (!hwndButton) return 0;
ShowWindow(hwndButton,SW_SHOW);
UpdateWindow(hwndButton);
while (GetMessage(&msg,NULL,0,0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
printf("In Message Loop");
if (msg.message == WM_LBUTTONDOWN) {
MessageBox(0,"Button Worked in main loop","Button Worked",MB_OK);
printf("Works!");
ShowWindow(hwndButton,SW_SHOW);
} // end if
if (msg.message == WM_DESTROY) {
printf("Quitting\n");
// exit(0);
} // end if
} // end while
}// end all
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
return DefWindowProc(hwnd, msg, wparam, lparam);
}
|
|
|
|
|
How to create a vitual driver like VFD software ?
Thank you a lot .
imagic
|
|
|
|
|
I just can't see why the following code doesn't change the text color to red.
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc = ::GetDC(hwnd);
HPEN pen = ::CreatePen(PS_SOLID, 3, RGB(255, 0, 0));
HGDIOBJ old;
old = ::SelectObject(&hdc, pen);
switch (message)
{
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
case WM_LBUTTONDOWN:
::TextOut(hdc, 100, 100, TEXT("Hello Windows"), 13);
::SelectObject(hdc, old);
return 0;
}
ReleaseDC (hwnd, hdc) ;
return ::DefWindowProc (hwnd, message, wParam, lParam) ;
}
//////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("RegisterClass Fail!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
HWND hwnd ;
hwnd = CreateWindow (szAppName,
TEXT ("The Hello Program"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
MSG msg ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
|
|
|
|
|
for change color text you can use
SetTextColor(hdc,RGB(255,0,0));
whitesky
|
|
|
|
|