Click here to Skip to main content
15,916,693 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Get the year... Pin
Naveen20-Dec-06 21:54
Naveen20-Dec-06 21:54 
GeneralRe: Get the year... Pin
Programm3r20-Dec-06 22:05
Programm3r20-Dec-06 22:05 
Questionexport text to pdf vc++/mfc. Pin
Murugan k20-Dec-06 20:58
Murugan k20-Dec-06 20:58 
AnswerRe: export text to pdf vc++/mfc. Pin
Cedric Moonen20-Dec-06 21:07
Cedric Moonen20-Dec-06 21:07 
Questionhow to maintain log file for a application? Pin
Banks K20-Dec-06 20:53
Banks K20-Dec-06 20:53 
AnswerRe: how to maintain log file for a application? Pin
Rage21-Dec-06 1:56
professionalRage21-Dec-06 1:56 
AnswerRe: how to maintain log file for a application? Pin
Chris Losinger21-Dec-06 3:17
professionalChris Losinger21-Dec-06 3:17 
QuestionAdding File names to list box. Pin
Suresh H20-Dec-06 20:43
Suresh H20-Dec-06 20:43 
Hello All,

I have a List Box { IDC_FILE_LIST } and add button { IDC_FILE }

When we click on the add button it should popup a window where we can browse some file name with path and it should be added to list box.
For that I have used the below code but I am getting errors can anyone please tell me what is wrong in the below code.

[code]

BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{

switch(Message)
{

case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_FILE:
OpenFile(hwnd);
break;


---
----

Function OpenFile : -

void OpenFile(HWND hwnd)
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";

ZeroMemory(&ofn, sizeof(ofn));

ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "txt";

if(GetOpenFileName(&ofn))
{
HWND hEdit = GetDlgItem(hwnd, IDC_FILE_LIST);
SendDlgItemMessage(hwnd, IDC_FILE_LIST, LB_ADDSTRING, 0, (LPARAM)ofn);
}

}

[\code]

Errors : -

(134) : error C2065: 'OPENFILENAME' : undeclared identifier
(134) : error C2146: syntax error : missing ';' before identifier 'ofn'
(134) : error C2065: 'ofn' : undeclared identifier
(139) : error C2228: left of '.lStructSize' must have class/struct/union type
(140) : error C2228: left of '.hwndOwner' must have class/struct/union type
(141) : error C2228: left of '.lpstrFilter' must have class/struct/union type
(142) : error C2228: left of '.lpstrFile' must have class/struct/union type
(143) : error C2228: left of '.nMaxFile' must have class/struct/union type
(144) : error C2228: left of '.Flags' must have class/struct/union type
(144) : error C2065: 'OFN_EXPLORER' : undeclared identifier
(144) : error C2065: 'OFN_FILEMUSTEXIST' : undeclared identifier
(144) : error C2065: 'OFN_HIDEREADONLY' : undeclared identifier
(145) : error C2228: left of '.lpstrDefExt' must have class/struct/union type
(147) : error C2065: 'GetOpenFileName' : undeclared identifier

---------
Thanking you,

Suresh HC





AnswerRe: Adding File names to list box. Pin
Mila02520-Dec-06 20:52
Mila02520-Dec-06 20:52 
GeneralRe: Adding File names to list box. Pin
Suresh H20-Dec-06 21:02
Suresh H20-Dec-06 21:02 
AnswerRe: Adding File names to list box. Pin
prasad_som20-Dec-06 20:53
prasad_som20-Dec-06 20:53 
GeneralRe: Adding File names to list box. Pin
Suresh H20-Dec-06 21:10
Suresh H20-Dec-06 21:10 
Questionprevent renaming an exe when it is running in windows Pin
seemadavid20-Dec-06 20:22
seemadavid20-Dec-06 20:22 
AnswerRe: prevent renaming an exe when it is running in windows Pin
nutkase20-Dec-06 20:28
nutkase20-Dec-06 20:28 
GeneralRe: prevent renaming an exe when it is running in windows Pin
seemadavid20-Dec-06 21:41
seemadavid20-Dec-06 21:41 
AnswerRe: prevent renaming an exe when it is running in windows Pin
Waldermort20-Dec-06 21:39
Waldermort20-Dec-06 21:39 
GeneralRe: prevent renaming an exe when it is running in windows Pin
seemadavid21-Dec-06 0:59
seemadavid21-Dec-06 0:59 
QuestionUnhandled exception at .... Pin
Programm3r20-Dec-06 20:11
Programm3r20-Dec-06 20:11 
AnswerRe: Unhandled exception at .... Pin
Cedric Moonen20-Dec-06 20:16
Cedric Moonen20-Dec-06 20:16 
GeneralRe: Unhandled exception at .... Pin
Programm3r20-Dec-06 20:23
Programm3r20-Dec-06 20:23 
GeneralRe: Unhandled exception at .... Pin
kakan20-Dec-06 20:39
professionalkakan20-Dec-06 20:39 
GeneralRe: Unhandled exception at .... Pin
Programm3r20-Dec-06 20:48
Programm3r20-Dec-06 20:48 
AnswerRe: Unhandled exception at .... Pin
Programm3r20-Dec-06 20:51
Programm3r20-Dec-06 20:51 
GeneralRe: Unhandled exception at .... Pin
kakan20-Dec-06 21:07
professionalkakan20-Dec-06 21:07 
GeneralRe: Unhandled exception at .... Pin
Programm3r20-Dec-06 21:08
Programm3r20-Dec-06 21:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.