Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Visionneuse API Windows

9 réponses
Avatar
Timothée Arnauld
Bonjour =E0 tous,
Voila, je cherche =E0 programmer une visionneuse de fichier .bmp =E0
partir d'un logiciel que j'ai deja cre=E9 (un editeur de texte) :)
Quelqu'un pourrait t'il m'aider a modifier mon code afin de pouvoir
realiser mon projet? :)

#include <windows.h>
#include <stdio.h>

#include "constantes.h"
#include "fonctions.h"

int WINAPI WinMain (HINSTANCE cetteInstance, HINSTANCE
precedenteInstance,
LPSTR lignesDeCommande, int modeDAffichage)
{
HWND hwnd;
MSG message;
WNDCLASS classeFenetre;

instance =3D cetteInstance;

classeFenetre.style =3D 0;
classeFenetre.lpfnWndProc =3D procedureFenetrePrincipale;
classeFenetre.cbClsExtra =3D 0;
classeFenetre.cbWndExtra =3D 0;
classeFenetre.hInstance =3D NULL;
classeFenetre.hIcon =3D LoadIcon(instance, MAKEINTRESOURCE (2));
classeFenetre.hCursor =3D LoadCursor(NULL, IDC_ARROW);
classeFenetre.hbrBackground =3D (HBRUSH)(1 + COLOR_BTNFACE);
classeFenetre.lpszMenuName =3D "ID_MENU";
classeFenetre.lpszClassName =3D "classeF";

if(!RegisterClass(&classeFenetre)) return FALSE;

hwnd =3D CreateWindow("classeF", "Aviator",WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT, 800,
600,
NULL, NULL,cetteInstance,
NULL);

if (!hwnd) return FALSE;

ShowWindow(hwnd, modeDAffichage);

while (GetMessage(&message, NULL, 0, 0))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
return message.wParam;
}

et pour mes fonctions:

#include <windows.h>
#include <stdio.h>

#include "constantes.h"
#include "fonctions.h"

LRESULT CALLBACK procedureFenetrePrincipale(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
static BOOL EditNotChg =3D FALSE;
switch (message)
{

case WM_TIMER:
{
switch (wParam)
case ID_B_TIMER:
DestroyWindow(hstatic);
return 0;
}

case WM_CREATE:
SetTimer(hwnd, ID_B_TIMER, 3000, (TIMERPROC)NULL);

hstatic =3D CreateWindowEx(WS_EX_TOPMOST ,"STATIC",
"MyPicture",
WS_POPUP | WS_VISIBLE | SS_BITMAP,
300, 250, 450, 300, hwnd,
NULL,
instance, NULL);

hEdit =3D CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "Texte",
WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN |
WS_VSCROLL,
0, 0, 0, 0, hwnd, NULL,
instance, NULL);
hFont =3D (HFONT)GetStockObject(ANSI_FIXED_FONT);
SendMessage(hEdit,WM_SETFONT,(UINT)hFont,TRUE);
SendMessage(hEdit, EM_SETMARGINS, EC_LEFTMARGIN |
EC_RIGHTMARGIN,
=20
MAKELONG(5, 5));
return 0;

case WM_CLOSE:
if(EditNotChg ||
MessageBox(hwnd,"Voulez-vous vraiment quitter?"
,"Quitter",MB_YESNO | MB_ICONQUESTION ) =3D=3D
IDYES)
=20
DestroyWindow(hwnd);
return 0;

case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_B_APROPOS:
DialogBox(instance, "APROPOS", hwnd,
(DLGPROC)aPropos_procedure);
break;
case ID_B_QUITTER:
if(EditNotChg ||
MessageBox(hwnd,"Voulez-vous vraiment quitter?"
,"Quitter",MB_YESNO | MB_ICONQUESTION ) =3D=3D
IDYES)
=20
DestroyWindow(hwnd); SendMessage(hwnd, WM_DESTROY, 0,
0);
break;
case EN_CHANGE:
EditNotChg =3D FALSE;
break;
case ID_B_OUVRIR:
charger();
break;
}
return 0;

case WM_SIZE:
MoveWindow(hEdit, 0, 0, LOWORD(lParam), HIWORD(lParam),
TRUE);
return 0;

case WM_DESTROY:
PostQuitMessage(0);
return 0;

default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
}

BOOL APIENTRY aPropos_procedure(HWND boiteDeDialogue,UINT
message,WPARAM wParam,LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:

return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) =3D=3D IDCANCEL || LOWORD(wParam) =3D=3D IDOK)
{
EndDialog(boiteDeDialogue,0);
return TRUE;
}
return 0;

default:
return FALSE;
}
}

void convert_multiple(char* buf)
{
int i;
for(i=3D0;;i++)
{
if (buf[i]=3D=3D'\0')
{
buf[i] =3D '\n';
if (buf[i+1]=3D=3D'\0')
break;
}
}
}

void charger()
{
OPENFILENAME ofn;
CHAR szFile[MAX_PATH]=3D{0};
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize =3D sizeof(OPENFILENAME);
ofn.lpstrFile =3D szFile;
ofn.nMaxFile =3D MAX_PATH;
ofn.lpstrFilter =3D
"Tout les fichiers\0*.*";
ofn.nFilterIndex =3D 1;
ofn.Flags =3D
OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST |
OFN_HIDEREADONLY;
if (GetOpenFileName(&ofn)=3D=3DTRUE)
{
HANDLE hf;
DWORD FileSize,nbcharRead ;
CHAR *buffer;

hf =3D CreateFile(szFile, GENERIC_READ, 0,NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
FileSize =3D GetFileSize(hf, NULL);
buffer =3D (PCHAR)LocalAlloc(LMEM_FIXED, FileSize+1);
ReadFile(hf, buffer, FileSize, &nbcharRead, NULL) ;
buffer[FileSize] =3D 0;
SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)buffer);
LocalFree(buffer);
CloseHandle(hf);
}
}

9 réponses

Avatar
Christian ASTOR
Timothée Arnauld a écrit :
Bonjour à tous,
Voila, je cherche à programmer une visionneuse de fichier .bmp à
partir d'un logiciel que j'ai deja creé (un editeur de texte) :)
Quelqu'un pourrait t'il m'aider a modifier mon code afin de pouvoir
realiser mon projet? :)



Il y a de nombreuses façons d'afficher des bmp et autres formats
Un classique est avec l'interface IPicture
Voir l'exemple Loadpic de la KB218972
Avatar
Timothée Arnauld
Et il y aurait un moyen de pouvoir voir ces possibilités?? :)
Avatar
Christian ASTOR
Timothée Arnauld a écrit :
Et il y aurait un moyen de pouvoir voir ces possibilités?? :)




Ben, l'exemple "Loadpic" de la KB218972 comme cité...
Avatar
Timothée Arnauld
Ah d'accord desole :$ Merci beaucoup! :)
Avatar
Timothée Arnauld
On 17 jan, 21:03, Timothée Arnauld wrote:
Ah d'accord desole :$ Merci beaucoup! :) Mais je suis aller voir et je co mprends pas trop...
Avatar
Christian ASTOR
Timothée Arnauld a écrit :
On 17 jan, 21:03, Timothée Arnauld wrote:
Ah d'accord desole :$ Merci beaucoup! :) Mais je suis aller voir et je comprends pas trop...





Tout étant commenté, je ne vois pas trop ce qui pose problème dans ce
code...
Avatar
Timothée Arnauld
Tout étant commenté, je ne vois pas trop ce qui pose problème dans ce
code...



Je suis desole parce que je me suis mal exprimé, ce que je comprend
pas c'est ou trouver ce "Loadpic" parce que j'ai cherché mais j'ai pas
trouvé :)
Avatar
Christian ASTOR
Timothée Arnauld a écrit :

Je suis desole parce que je me suis mal exprimé, ce que je comprend
pas c'est ou trouver ce "Loadpic" parce que j'ai cherché mais j'ai pas
trouvé :)



http://lmgtfy.com/?q=KB218972
Avatar
Timothée Arnauld
http://lmgtfy.com/?q=KB218972



Merci beaucoup :)